Archived

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

Gf11speed

Restoring Full Screen DirectX App.

Recommended Posts

With my game, for some reason, when I hit ALT-TAB and flip out of the game, and try to get back in it, it won''t let me. For some reason the game won''t come back on once its been downsized. How can I get the game to resume where it left off if I downsize it? Thanks!!! ---------- www.syntasoft.com ------------------

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
i am taiwanese, so my english no good, i use DirectX 7
------------------------------------------------------
hook WM_ACTIVATE message

case WM_ACTIVATE:
if(LOWORD(wParam) == WA_INACTIVE || (BOOL)HIWORD(wParam))
{
Pause(TRUE); /* pause */
}
else /*if(LOWORD(wParam) == WA_ACTIVE) ||
LOWORD(wParam) == WA_CLICKACTIVE))*/
{
Pause(FALSE); /* no pause */
}
------------------------------------------------------
no hook WM_SIZE message
------------------------------------------------------
this is Microsoft examples Flip,i modify it,

Flip:
/* get client rect */
if(m_bFullScreen)
{
GetWindowRect(m_hwndOwner, &rcDest);
}
else
{
GetClientRect(m_hwndOwner, &rcDest);
ClientToScreen(m_hwndOwner, (LPPOINT)&rcDest);
ClientToScreen(m_hwndOwner, (LPPOINT)&rcDest+1);
}

/* check lost surface */
if(m_pPrimaryBuffer->IsLost() == DDERR_SURFACELOST)
{
hr = m_pPrimarySurface->Restore();
if(hr == DDERR_WRONGMODE)
{
Free(); /* My Free DirectDraw */
return Create(); /* My Create DirectDraw */
}
if( FAILED(hr) ) return E_FAIL;

if(m_pBackBuffer->IsLost() == DDERR_SURFACELOST)
{
hr = m_pBackBuffer->Restore();
if( FAILED(hr) ) return E_FAIL;
}
}

/* flip */
if(m_bFullScreen)
{
while(TRUE)
{
hr = m_pPrimaryBuffer->Flip(NULL, DDFLIP_WAIT);
if(hr == DD_OK) break;
if(hr == DDERR_SURFACELOST)
{
hr = m_pPrimaryBuffer->Restore();
if( FAILED(hr) ) break;
}
if(hr != DDERR_WASSTILLDRAWING) break;
}
}
else
{
while(TRUE)
{
hr = m_pPrimaryBuffer->Blt(&rcDest, m_pBackSurface, NULL, DDBLT_WAIT, NULL);
if(hr == DD_OK) break;
if(hr == DDERR_SURFACELOST)
{
hr = m_pPrimaryBuffer->Restore();
if( FAILED(hr) ) break;
}
if(hr != DDERR_WASSTILLDRAWING) break;
}
}
------------------------------------------------------
good luck.

Share this post


Link to post
Share on other sites