OLESTATUS OleDraw(lpObject, hdc, lprcBounds, lprcWBounds, hdcFormat)
LPOLEOBJECT lpObject;
HDC hdc;
const RECT FAR* lprcBounds;
const RECT FAR* lprcWBounds;
HDC hdcFormat;
The OleDraw function draws a specified object into a bounding rectangle in a device context.
Parameter | Description |
lpObject | Points to the object to draw. |
hdc | Identifies the device context in which to draw the object. |
lprcBounds | Points to a RECT structure defining the bounding rectangle (in logical units for the device context specified by the hdc parameter) in which to draw the object. |
lprcWBounds | If the hdc parameter is not a handle to metafile, lprcWBounds (this parameter) should be NULL. If hdc is a metafile, then lprcWBounds points to a special RECT structure defining the bounding rectangle of the window to be drawn. |
hdcFormat | Identifies a device context describing the target device for which to format the object. |
The client DLL may use an object handler to render the object, and this object handler may need information about the target device. Therefore, the device-context handle specified by the hdcFormat parameter is required. The lprcBounds parameter identifies the rectangle on the device context (relative to its current mapping mode) that the object should be mapped onto. This may involve scaling the picture and can be used by client applications to impose a view scaling between the displayed view and the final printed image.
An object handler should format an object as if it were to be drawn at the size specified by a call to the OleSetBounds function for the device context specified by the hdcFormat parameter. Often this formatting will already have been done by the server application; in this case, the DLL simply renders the presentation data with suitable scaling for the required bounding rectangle. If cropping or banding is required, the device context in which the object is drawn may include a clipping region smaller than the specified bounding rectangle.
When the hdc parameter specifies a metafile device context, the rectangle specified by the lprcWBounds parameter contains the coordinate system that will be used by the metafile. Unlike normal RECT structures, the left and top members of the RECT structure should specify the window origin, and the right and bottom members should specify the window extents. The following sample code illustrates how the lprcWBounds parameter is set and used for metafiles using the MM_ANISOTROPIC mapping mode:
hdc = CreateMetaFile (NULL);
SetWindowOrg (hdc, xOrg, yOrg);
SetWindowExt (hdc, xExt, yExt);
lprcWBounds->left = xOrg;
lprcWBounds->top = yOrg;
lprcWBounds->right = xExt;
lprcWBounds->bottom = yExt;
OleDraw (lpobject, hdc, lprcBounds, lprcWBounds, NULL);
hmf = CloseMetaFile(hdc);
The return value is OLE_OK if successful; otherwise, it could be one of the following:
OLE_ERROR_ABORT
OLE_ERROR_BLANK
OLE_ERROR_DRAW
OLE_ERROR_HANDLE
OLE_ERROR_MEMORY
OLE_ERROR_OBJECT
This function returns OLE_ERROR_ABORT if the callback function returns FALSE during drawing.
See AlsoOleSetBounds