Default Device Windows

You can choose to let DirectDraw create, manage, and destroy device windows for you. For simplicity, the windows that DirectDraw manages are referred to as "default device windows." Although using default device windows frees you from the tasks of creating and destroying device windows on your own, your application will not receive the mouse-related messages that the operating system sends to those default device windows. Therefore, you should choose to use default device windows only if your application does not need to receive mouse-related messages for device windows.

Enabling default device windows is simple. After setting a DirectDraw object's focus window in the first call to IDirectDraw2::SetCooperativeLevel, call the method again, specifying a combination of the DDSCL_CREATEDEVICEWINDOW, DDSCL_FULLSCREEN, and DDSCL_EXCLUSIVE flags for the dwFlags parameter.

Note that it is possible to set a DirectDraw object's focus window, tell DirectDraw to create a default device window, and set the cooperative level in a single call to SetCooperativeLevel. The following example shows how this can be done:

/*
 * This code fragment is only valid 
 * when using default device windows.
 */
HRESULT hr;
hr = g_lpDD->SetCooperativeLevel(
                // This window handle is ONLY for the focus window.
                hwndFocus,
                DDSCL_SETFOCUSWINDOW | DDSCL_FULLSCREEN |
                DDSCL_EXCLUSIVE | DDSCL_CREATEDEVICEWINDOW);