Alex Rivera | Logout

How to determine if the current window is the active window?

Asked 2009-02-04T10:50:19.673
10

How can I tell if my window is the current active window? My current guess is to do GetForegroundWindow and compare the HWND with that of my window. Is there a better method than that?

I'm using Win32 API / MFC.

Edit
Report

1 Answer

1

I assume that you mean the window which has the input focus when you say "active window"?

In that case, forget the GetForegroundWindow() API. That will return the topmost window - not always the window which has the input focus.

Use GetFocus() instead.

answered 2009-02-04T13:27:35.160

Your Answer