Jump to content
  • Advertisement

Archived

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

Muzlack

Alt-tabbing

This topic is 5668 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 am using DirectDraw. Whenever some1 alt-tabs out of the game, and comes back, the screen is black. Is it possible to fix this? I''ve seen it done in other directdraw games.... maybe the surface->Restore() function?

Share this post


Link to post
Share on other sites
Advertisement
You''ll have to test to see if your window loses focus, and then check to see when it regains focus. At that point, you redraw the entire screen.

I think you''ll have to monitor some WM_ messages, maybe WM_FOCUS or somesuch. Hope this points you in the right direction.

£§

Share this post


Link to post
Share on other sites
Yep, you''ll need to restore all of your surfaces, and the contents of them too I think. You can consult the DirectX documentation for more details, ''cos I can''t remember them.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
look in the docs

IDirectDraw7::TestCooperativeLevel

and I think this exists but i cant remember

IDirectDraw7::RestoreAllSurfaces

Share this post


Link to post
Share on other sites
You don't need to reinitialize DirectDraw. It's there already. What you need to do is to call Restore() for each surface, if successful, redraw the bitmap .


500

[edited by - alnite on February 8, 2003 11:50:25 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Is there a way to disable the Alt-Tab function while your game is running?

Kevin

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by Anonymous Poster
Is there a way to disable the Alt-Tab function while your game is running?

Kevin

You should NOT attempt to disable alt-tab.

Windows applications should/must be able to handle losing focus & regaining focus.

Disabling alt-tab will not make the problem go away.

Get use to it.




Share this post


Link to post
Share on other sites
Anon is right, simply don''t attempt to disable alt+tabbing.

Here''s my function from my old dx7 codebase:


  
///////////////////////////////////////////////////////////////////////////////

// MonitorAltTab()

// Check if the user has alt+tabbed away from the app

//

void CApplication::MonitorAltTab()
{

HRESULT hr = Direct3DSystem.lpDD->TestCooperativeLevel();

if (hr == DDERR_NOEXCLUSIVEMODE)
{

MainTimer.TimerPause(); // pause the system timer so we don''t get any screwy frame rates


// temporarly relenquish ownership of any DInput devices

for (unsigned int t = 0; t < DInputSystem.GetMaxDevices(); t ++)
{
if (DInputSystem.m_pcDevices[t] != NULL)
{
DInputSystem.m_pcDevices[t]->Unacquire();
}
}

#ifdef _DEBUGMSGS // some messages for the debug stream
LONGLONG TimeNow = MainTimer.PauseTime;

char buffer[256];
sprintf(buffer, "App paused at: %i", TimeNow);
AppDebugLog.PrintLine(buffer);
#endif

MSG msg;

WaitMessage(); // suspend the application




do // wait inside this message pump until the coop level is restored

{
int bGotMsg = PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE );

if (bGotMsg)
{
// TranslateMessage(&msg);

DispatchMessage(&msg);

hr = Direct3DSystem.lpDD->TestCooperativeLevel();
}
}while (hr != DD_OK);

// regain ownership of any DInput devices..

for (t = 0; t < DInputSystem.GetMaxDevices(); t ++)
{
if (DInputSystem.m_pcDevices[t] != NULL)
{
DInputSystem.m_pcDevices[t]->Acquire();
}
}

// Update the system...

Direct3DSystem.CheckSurfaces(); // check the primary, back and z buffers

TextureSystem.CheckTextures(); // check every texture


//. start the system timer running again

MainTimer.TimerContinue();

#ifdef _DEBUGMSGS
sprintf(buffer, "App restored at: %i", MainTimer.LastTime );
AppDebugLog.PrintLine(buffer);
#endif
}


}



With some of it you''ll just have to follow the logic like "TextureSystem.CheckTextures();" is calling another function but it''s purpose should be self explanatory. The rest of it like, testing for coop level and waiting for it to be restored, can be copied.

- Matt

Share this post


Link to post
Share on other sites
Thanks for that... I have a question though. CheckSurfaces... DOes this function do something like this?

[script]
if(surface->Restore() ) {
surface=DDLoadBitmap("bitmap",0,0);
}

[/script]

Something like this? (I''m basing this code off of what other people have said to do in this thread )

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!