• Announcements

Archived

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

Has anybody ever gotten Alt+TAB working ?

Recommended Posts

thorpe    122
I have tried absolutely everything and I just can''t get it working. It just seems impossible... This is the code I use at the moment: case WM_SETFOCUS: SetCursor(0); ACTIVE=TRUE; if(FOCUSLOST){ Beacon(123); while(g_pDDSPrimary->Flip(0, DDFLIP_WAIT)==DDERR_SURFACELOST){ g_pDDSPrimary->Restore(); g_pDDSBack->Restore(); Beacon(1234); } RestoreAll(); ReacquireInput(); if(GameStatus==PLAY&&PlayStatus==PLAYING){ if(PAUSE) Pause(); BLIT=TRUE; Blitted=0; } FOCUSLOST=FALSE; } return 0; case WM_KILLFOCUS: ACTIVE=FALSE; FOCUSLOST=TRUE; ACTIVE=FALSE; for(int Y=0;YFlip(0, DDFLIP_WAIT)==DDERR_SURFACELOST) loop when I reactivate the app. Am I supposed to use WM_KILLFOCUS and WM_SETFOCUS or something else? Is there anythinig else I need to think of? Please help me, I''m really desperate! Johan Torp - http://www.destruction.nu

Share on other sites
Guest Anonymous Poster
take a look at
IDirectDraw7::TestCooperativeLevel()
in the dx7 sdk docs

Share on other sites
Have you read the section on this in the DX8 SDK docs? Use IDirect3DDevice8::TestCooperativeLevel() to check if the device is ready to be reset (ie your app has regained focus). If it is then you need to reset it with IDirect3DDevice8::Reset().

Also make sure the D3DPRESENT_PARAMETERS you are supplying to Reset() still contains correct values.

Other than that you need to restore IBs, VBs and textures that were in D3DPOOL_DEFAULT memory.

I personally don''t run my main loop when the device is lost, I just call a function that checks is a reset is possible, and then attempts to reset if it is.

Good luck

Share on other sites
thorpe    122
I have now looked a little on testcooperativelevel though I''m not sure how to use it. Should I loop until it returns DD_OK in the WM_SETFOCUS case, before restoring surfaces? I''ll give it a try... In the meantime, does anybody have any example or an article on how to get this working?

Btw, I am not using d3d.

I have been trying for several days now so I really appreciate your help.

Johan Torp - http://www.destruction.nu

Share on other sites
3dModelMan    204
Try keep the program in a loop until the cooperative level is restored, like this;

  HRESULT hr = lpDD->TestCooperativeLevel();if (hr == DDERR_NOEXCLUSIVEMODE){ MSG msg; WaitMessage(); // the app will now pause do // wait inside this message pump until //the coop level is restored { int bGotMsg = PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ); if (bGotMsg) { DispatchMessage(&msg); hr = lpDD->TestCooperativeLevel(); } }while (hr != DD_OK);}

I found that just waiting for the initial message was not enough, and I could receive 4 or 5 messages before the cooperation level was restored.

- Matt

Share on other sites
>> Btw, I am not using d3d.

Share on other sites
thorpe    122
>>>> Btw, I am not using d3d.

You tried to help me at least =). I wouldn''t have read all that code either!

Just thought I''d tell you all that I finally got it working!!!

3dModelMan, thank you for the tip and the code and I want to thank all others who tried to help =) I never thought I''d get it working!

Johan Torp - http://www.destruction.nu