Platform SDK: DirectX |
The information in this topic pertains only to applications written in C++.
There are two ways to set a device window:
The following example sets an existing device window for the DirectDraw object represented by lpDD.
/* It is presumed that lpDD is a valid IDirectDraw interface pointer, and that hWnd is the handle to an appropriate device window. */ HRESULT hr = lpDD->SetCooperativeLevel( hWnd, DDSCL_SETDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN );
The following example sets a default device window created by DirectDraw. In this case, hWnd is the handle to the existing focus window.
HRESULT hr = lpDD->SetCooperativeLevel( hWnd, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN );
Although a focus window can be a device window, you cannot set a window as both the focus window and a device window with a single call to SetCooperativeLevel. You must first set it as the focus window and then set it as a device window. However, it is possible to set a focus window and a default device window on the same device with a single call to SetCooperativeLevel. The following example shows how this can be done.
HRESULT hr = lpDD->SetCooperativeLevel( hwndFocus, DDSCL_SETFOCUSWINDOW | DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_CREATEDEVICEWINDOW);
In this example, an existing window (probably the application window) is set as the focus window, and DirectDraw creates a default device window.