This topic is now archived and is closed to further replies.

if (WM_ACTIVE) bFocus = true; What exactly does bFocus do?

This topic is 5274 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

I''ve seen it this piece of code:
if (msg == WM_ACTIVATE)
  if (LOWORD(wparam) == WA_INACTIVE)
    bFocus = FALSE;
    bFocus = TRUE;

  // tell Windows we handled it

what does bFocus do? is it supposed to be used somewhere else? it seems pretty useless from where it is now.

Share this post

Link to post
Share on other sites
If it's false the window doesn't have focus and doesn't need to do anything except wait for the next message. If you're using GetMessage() everything is fine, it will block until a new message arrives. If you are using PeekMessage() you will keep calling it even though your window might not have any messages because it's not in focus. So, in your PeekMessage loop add:

if (bFocus == FALSE)

Forgot to mention, only do that or use GetMessage() if your program can afford to hold when not in focus. If you have to do anything in the background, even if the user is away (network comm for example), it will get suspended as well, so use PeekMessage and don't check for focus.

- outRider -

[edited by - outRider on July 5, 2003 2:58:05 PM]

Share this post

Link to post
Share on other sites