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


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

Recommended Posts

Alpha_ProgDes    6921
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
outRider    852
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
Alpha_ProgDes    6921
i''m not doing anything like networking.
i saw it in one of the articles here and couldn''t see how to use it correctly.

just wanted to know how to use in a game loop or any other loop for that matter.

Share this post

Link to post
Share on other sites