The OleDraw helper function can be used to draw objects more easily. You can use it instead of calling IViewObject::Draw directly.
WINOLEAPI OleDraw(
IUnknown * pUnk, //Pointer to the view object to be drawn
DWORD dwAspect, //How the object is to be represented
HDC hdcDraw, //Device context on which to draw
LPCRECT lprcBounds //Pointer to the rectangle in which the object
// is drawn
);
This function supports the standard return values E_INVALIDARG and E_OUTOFMEMORY, as well as the following:
The OleDraw helper function calls the QueryInterface method for the object specified (pUnk), asking for an IViewObject interface on that object. Then, OleDraw converts the RECT structure to a RECTL structure, and calls IViewObject::Draw as follows:
lpViewObj->Draw(dwAspect,-1,0,0,0,hdcDraw,&rectl,0,0,0);
Do not use OleDraw to draw into a metafile because it does not specify the lprcWBounds parameter required for drawing into metafiles.
Windows CE: Passing into this function any invalid and, under some circumstances, NULL pointers will result in unexpected termination of the application. For more information about handling exceptions, see Programming Considerations.
Windows NT: Use version 3.1 or later.
Windows: Use Windows 95 or later.
Windows CE: Use version 2.0 or later.
Header: Declared in ole2.h.
Import Library: Included as a resource in ole32.dll.