Jump to content
  • Advertisement


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


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

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

  • 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!