Jump to content
  • Advertisement

Archived

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

Qoy

Maximizing

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

Is there something special you have to do when maximizing DirectX programs? In my WM_ACTIVATE handler, I restore all the ddraw surfaces and re-acquire all my dinput devices (I am not using DirectSound or anything else), but the program wont maximize again. What could the problem be?

Here is the current code:
case WM_ACTIVATEAPP:
{
if(activated) // activated is set the first time the game window is activated
{
BOOL fActive = (BOOL)wParam;
if(fActive == TRUE)
{
// reacquire dinput devices
keyboard->Acquire();

// restore ddraw surfaces
if(primaryBuffer->IsLost())
{
while(FAILED(primaryBuffer->Restore()))
WaitMessage();
}
if(backBuffer->IsLost())
{
while(FAILED(backBuffer->Restore()))
WaitMessage();
}

// put the game back to the previous state
gameState = prevGameState;
}
else
{
// take down the current state and set the new state
// so that it wont try to update anything
prevGameState = gameState;
gameState = GAME_STATE_NULL;
}
}
} break;

sorry about the bad spacing


------------------------ http://qoy.tripod.com

[This message has been edited by Qoy (edited November 12, 1999).]

Share this post


Link to post
Share on other sites
Advertisement
First, you seem to be using activated only once, when the game window is activated the first time, but you are not reseting it anywhere in the function.

Secondly, this might be better in the windows message handler: WM_ACTIVATE:

Lastly, I think fActive would better be set by checking the status passed in wParam, not using it to set a flag.

The loword of wParam holds a couple values. The one you should check for is WA_INACTIVE.

So, I suggest:

case WM_ACTIVATE:
// check what happended
// activated or deactivated
BOOL fActive = TRUE;
if(LOWORD(wParam) == WA_INACTIVE)
fActive = FALSE;

if(fActive == TRUE) {
// reacquire dinput devices
keyboard->Acquire();
primaryBuffer->Restore();
backBuffer->Restore();

// put the game back to the previous state
gameState = prevGameState;
} else {
// take down the current state and set the new state
// so that it wont try to update anything
prevGameState = gameState;
gameState = GAME_STATE_NULL;
}
return 0;

Jim Adams

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!