Sign in to follow this  
_Phalanx_

How to make windowed games share the CPU

Recommended Posts

There are probably many ways to do this, but one way is to listen for the WM_ACTIVATE event to determine when your window becomes inactive. When it does, call whatever code you need to pause your game, and then set a flag. That flag should trigger your main loop to call WaitMessage() instead of calling your game logic. WaitMessage will cause your program to stop running until your window recieves a message. When you get another WM_ACTIVATE message that indicates your window is active, unpause the game and reset the flag.

Share this post


Link to post
Share on other sites
So are you saying i recieve a WM_ACTIVATE message everytime the window is activated OR inactivated, or do i recieve a WM_INACTIVATE message when I go to another window and a WM_ACTIVATE when it is activated?

if possible, i dont want to pause this window myself, i notice windows does a nice job of pausing while i move or resize the window. It pauses the window clock and as far as i can see basically does nothing untill you are done your moving or resizing. I was wondering if there was some way i could tell windows to pause it like that when it isnt being used. This allows me to have even less unnecesary cpu time used and it makes it easier for me to code :D

thanks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this