🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Maximizing

Started by
0 comments, last by Qoy 24 years, 7 months ago
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).]

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

This topic is closed to new replies.

Advertisement