Microsoft DirectX 9.0

IDirectDrawFactory::CreateDirectDraw

Note   The IDirectDrawFactory interface is deprecated.

Creates a DirectDraw object and retrieves a pointer to its IDirectDraw interface.

Syntax

STDMETHOD CreateDirectDraw(
    GUID *pGUID,
    HWND hWnd,
    DWORD dwCoopLevelFlags,
    DWORD dwReserved,
    IUnknown *pUnkOuter,
    IDirectDraw **ppDirectDraw
);

Parameters

pGUID

[out] Pointer to the globally unique identifier (GUID) that represents the driver to be created. Set this to NULL to indicate the active display driver, or you can pass one of the following flags to restrict the active display driver's behavior for debugging purposes.

Value Description
DDCREATE_EMULATIONONLY The DirectDraw object will use emulation for all features; it will not take advantage of any hardware-supported features.
DDCREATE_HARDWAREONLY The DirectDraw object will never emulate features not supported by the hardware. Attempts to call methods that require unsupported features will fail, returning DDERR_UNSUPPORTED (operation not supported).

hWnd

[in] Window handle to the application.

dwCoopLevelFlags

[in] Application's top-level behavior. Specify one or more of the following flags.

Value Description
DDSCL_ALLOWMODEX Enables the use of Mode X display modes. You must use this flag with the DDSCL_EXCLUSIVE and DDSCL_FULLSCREEN flags.
DDSCL_ALLOWREBOOT Enables the user to reboot by pressing CTRL+ALT+DEL while the application is in full-screen exclusive mode.
DDSCL_EXCLUSIVE Requests the exclusive level. You must use this flag with the DDSCL_FULLSCREEN flag. At the full screen and exclusive cooperative level, you can use the hardware to its fullest. In this mode, you can set custom and dynamic palettes, change display resolutions, compact memory, and implement page flipping. The exclusive (full-screen) mode does not prevent other applications from allocating surfaces, nor does it exclude them from using DirectDraw or GDI. However, it does prevent applications other than the one currently with exclusive access from changing the display mode or palette.
DDSCL_FULLSCREEN Indicates that the exclusive-mode owner will be in control of the entire primary surface. You must use this flag with the DDSCL_EXCLUSIVE flag.
DDSCL_NORMAL Indicates that the application will function as a regular Microsoft® Windows® application. You can't use this flag with the DDSCL_ALLOWMODEX, DDSCL_EXCLUSIVE, or DDSCL_FULLSCREEN flags.
DDSCL_NOWINDOWCHANGES Indicates that DirectDraw can't minimize or restore the application window when the application is activated.

dwReserved

[in] Reserved. Must be NULL.

pUnkOuter

[in] Reserved. Must be NULL.

ppDirectDraw

[out] Address of a pointer to an IDirectDraw interface.

Return Value

Returns DD_OK if successful, or one of the following error values otherwise.

Return code Description
DDERR_DIRECTDRAWALREADYCREATED A DirectDrawEx object representing this driver has already been created for this process.
DDERR_GENERIC There is an undefined error condition.
DDERR_INVALIDDIRECTDRAWGUID The GUID passed to this method is not a valid DirectDrawEx driver identifier.
DDERR_INVALIDPARAMS One or more of the parameters passed to the method are incorrect.
DDERR_NODIRECTDRAWHW Hardware-only DirectDrawEx object creation isn't possible; the driver doesn't support any hardware.
DDERR_UNSUPPORTED DirectDraw doesn't support the operation.
E_OUTOFMEMORY There isn't enough memory available to create a DirectDraw object.

Remarks

This method creates DirectDraw objects in the same way that the DirectDraw DirectDrawCreate function is used to create DirectDraw objects, and sets cooperative levels the same way the IDirectDraw2::SetCooperativeLevel method sets cooperative levels. However, in addition to creating a DirectDraw object, successful calls to the IDirectDrawFactory::CreateDirectDraw method will obtain a pointer to the IUnknown and IDirectDraw interfaces, which are exposed on the DirectDraw object. Applications can now query the DirectDraw object to obtain the address of a pointer to an IDirectDraw3 interface.

See Also