Jump to content
  • Advertisement
Sign in to follow this  

window activation and deactivation

This topic is 3295 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I have a windows fullscreen openGL application and wrote a function called "OnFocusChange(bool a)". When the user presses alt+tab, that function should be called with 'false' as an argument. When the user focusses the window again, the function should be called with the argument 'true'; The "OnFocusChange" function takes care of changing the screen settings (that's all for now). I have the following code in my WindowProc function:
LRESULT CALLBACK App::WndProc(HWND hWnd, UINT msg, WPARAM wparam, LPARAM lparam)
bool activating;

if(!pApp) return DefWindowProc(hWnd, msg, wparam, lparam);


activating = ( (LOWORD(wparam) != WA_INACTIVE) && (HIWORD(wparam) == 0) );


return FALSE;
This code does make sure "OnFocusChange" is called on activating and deactivating the window, but there's a bug. "OnFocusChange" is also called when other windows are activated or deactivated, while the state of my application's window doesn't change. Does somebody see what's going wrong and how I could change the code to get what I want?

Share this post

Link to post
Share on other sites
Don't know if this is correct or not but in my code (not full screen) I have

WM_SETFOCUS and WM_KILLFOCUS. According to msdn:

The WM_SETFOCUS message is sent to a window after it has gained the keyboard focus.
The WM_KILLFOCUS message is sent to a window immediately before it loses the keyboard focus.

Perhaps you could try those instead.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!