IDirectDrawFactory Interface


The IDirectDrawFactory interface is used to create and enumerate DirectDraw objects that support the extended features of DirectDrawEx (see Using DirectDrawEx for more information).

When to Implement

Do not implement this interface; DirectDrawEx implements it for you.

When to Use

Use this interface in an application when you want to create a DirectDrawEx object.

Methods in Vtable Order
IUnknown methods Description
QueryInterface Retrieves pointers to supported interfaces.
AddRef Increments the reference count.
Release Decrements the reference count.
IDirectDrawFactory methods Description
CreateDirectDraw Creates a DirectDraw object and retrieves pointers to the IUnknown and the IDirectDraw interfaces.
DirectDrawEnumerate Enumerates the DirectDraw surfaces installed on the system.


IDirectDrawFactory::CreateDirectDraw

IDirectDrawFactory Interface

Creates a DirectDraw object and retrieves pointers to the IUnknown and the IDirectDraw interfaces.

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

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 Meaning
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 Meaning
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 CTRL+ALT+DEL to function while in exclusive (full-screen) mode.
DDSCL_EXCLUSIVE Requests the exclusive level. You must use this flag with the DDSCL_FULLSCREEN flag.
DDSCL_FULLSCREEN Indicates that the exclusive-mode owner will be responsible for the entire primary surface. GDI can be ignored. You must use this flag with the DDSCL_EXCLUSIVE flag.
DDSCL_NORMAL Indicates that the application will function as a regular 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 on activation.
dwReserved
[in] Reserved for future use. Must be NULL.
pUnkOuter
[in] Pointer to an IUnknown interface on an outer object that will be aggregated with an inner object's IUnknown interface.
ppDirectDraw
[out] Address of a pointer to an IDirectDraw interface.
Return Values

Returns DD_OK if successful, or one of the following error values otherwise:
Value Meaning
E_OUTOFMEMORY There isn't enough memory available to create a DirectDrawEx object.
DDERR_GENERIC There is an undefined error condition.
DDERR_UNSUPPORTED The operation isn't supported.
DDERR_DIRECTDRAWALREADYCREATED A DirectDrawEx object representing this driver has already been created for this process.
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.

Remarks

This method creates DirectDraw objects in the same way that the 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 to obtain the address of a pointer to an IDirectDraw3 interface.


IDirectDrawFactory::DirectDrawEnumerate

IDirectDrawFactory Interface

Enumerates the DirectDraw objects installed on the system.

STDMETHOD DirectDrawEnumerate(
  LPDDENUMCALLBACK lpCallback,
  LPVOID lpContext
  ) PURE;

Parameters
lpCallback
[in] Pointer to a DDEnumCallback function that will be called with a description of each DirectDrawEx-enabled hardware abstraction layer (HAL) installed in the system.
lpContext
[in] Address of an application-defined structure that will be passed to the callback function each time the function is called.
Return Values

Returns DD_OK if successful, or DDERR_INVALIDPARAMS otherwise.

Remarks

This method functions in a similar manner to the DirectDrawEnumerate function, defined in the DirectX SDK.

Note This method can only be called by your application after a successful call to the IDirectDrawFactory::CreateDirectDraw method.

© 1997 Microsoft Corporation. All rights reserved. Terms of Use.