Platform SDK: DirectX |
The information in this topic pertains only to applications written in C++.
DirectDrawClipper objects have full class-factory support for COM compliance. In addition to using the standard DirectDrawCreateClipper function and IDirectDraw7::CreateClipper method, you can also create a DirectDrawClipper object either by using the CoGetClassObject function to obtain a class factory and then calling the CoCreateInstance function, or by calling CoCreateInstance directly. The following example shows how to create a DirectDrawClipper object by using CoCreateInstance and the IDirectDrawClipper::Initialize method.
ddrval = CoCreateInstance(&CLSID_DirectDrawClipper, NULL, CLSCTX_ALL, &IID_IDirectDrawClipper, &lpClipper); if (!FAILED(ddrval)) ddrval = IDirectDrawClipper_Initialize(lpClipper, lpDD, 0UL);
In this call to CoCreateInstance, the first parameter, CLSID_DirectDrawClipper, is the class identifier of the DirectDrawClipper object class, the IID_IDirectDrawClipper parameter identifies the currently supported interface, and the lpClipper parameter points to the DirectDrawClipper object that is retrieved.
An application must use the IDirectDrawClipper::Initialize method to initialize DirectDrawClipper objects that were created by the class-factory mechanism before it can use the object. The value 0UL is the dwFlags parameter, which in this case has a value of 0 because no flags are currently supported. In the example shown here, lpDD is the DirectDraw object that owns the DirectDrawClipper object. However, you could supply a NULL value instead, which would create an independent DirectDrawClipper object. (This is equivalent to creating a DirectDrawClipper object by using the DirectDrawCreateClipper function.)
Before you close the application, close the COM library by using the CoUninitialize function.