Original Post
Hi, everybody!
My DirectDraw application loads about 50 bitmaps in 50 different surfaces. I use the following loop to ensure that when it is minimized and than back restored it will pause without any problems:
//-----CODE BEGIN-----//
HRESULT hFirstRes = lpdd->TestCooperativeLevel();
while (lpdd->TestCooperativeLevel() != DD_OK)
{
WaitMessage();
MessageLoop();
}
if (hFirstRes != DD_OK)
{
HRESULT hRes = lpdd->RestoreAllSurfaces();
assert(hRes == DD_OK);
//reload all bitmaps
}
//-----CODE END-----//
It works fine except in the following situation: during loading the bitmaps and creating the surfaces other window comes active. In that case the main loop will pause because TestCooperativeLevel() indicates that the app has lost excusive and fullscreen mode. But when switching back to my app RestoreAllSurfaces() returns DDERR_WRONGMODE(This surface can not be restored because it was created in a different mode).
It is true that some of the surfaces are created when the app is minimized because the other window is active in that moment. In that moment the screen resolution is 1024x768x16 (my desktop resolution) and my app has 800x600x16 resolution. When I change the desktop resolution to 800x600x16 and try again, the DDERR_WRONGMODE error is substituted with DDERR_OUTOFVIDEOMEMORY.
What is wrong with creating the surfaces when the main app window is minimized and the resolution is differnt? Does it mean that I can''t create any surfaces before the screen resolution is changed with SetDisplayMode()? Is a good solution to hold my app window active by force in some way and ensure that the surfaces are created in the appropriate display mode?
Best wishes, Ivan.