I did a search but could not find this, though I'm sure it's been answered before.
I need to be able to test whether my MDI app has the focus or not.
What's the best way to do this?
Printable View
I did a search but could not find this, though I'm sure it's been answered before.
I need to be able to test whether my MDI app has the focus or not.
What's the best way to do this?
The following should work:Code:if(CWnd::GetFocus()->GetSafeHwnd() == AfxGetMainWnd()->GetSafeHwnd())
{
// Our App's main window has focus
}
doesn't.
What exactly is not working? Did you look at the values returned by GetFocus()->GetSafeHwnd() and AfxGetMainWnd()->GetSafeHwnd() and looked them up in Spy++? Could it be that a child window (and not the main window) actually has the focus when you are testing?