DirectX SDK |
The information in this section pertains only to applications written in C and C++. See DirectDraw Visual Basic Tutorials.
When you do not need the overlay surface anymore, or if you simply want to remove it from view, you can hide the surface by calling the IDirectDrawSurface7::UpdateOverlay method with the appropriate flags. Mosquito hides the overlay in preparation for closing the application using the following code:
void DestroyOverlay() { if (g_lpddsOverlay){ // Use UpdateOverlay() with the DDOVER_HIDE flag to remove an overlay // from the display. g_lpddsOverlay->UpdateOverlay(NULL, g_lpddsPrimary, NULL, DDOVER_HIDE, NULL); g_lpddsOverlay->Release(); g_lpddsOverlay=NULL; } }
When the preceding example calls IDirectDrawSurface7::UpdateOverlay, it specifies NULL for the source and destination rectangles, because they are irrelevant when hiding the overlay. Similarly, the example uses NULL in the fifth parameter because overlay effects aren't being used. The second parameter is a pointer to the target surface. Lastly, the example uses the DDOVER_HIDE flag in the fourth parameter to indicate that the overlay will be removed from view.
After the example hides the overlay, the example releases its IDirectDrawSurface7 interface and invalidates its global variable by setting it to NULL. For the purposes of the Mosquito sample application, the overlay surface is no longer needed. If you still need the overlay surface for later, you could simply hide the overlay without releasing it, then redisplay it whenever you require.