OleDraw

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
);
 

Parameters

pUnk
[in] Pointer to the IUnknown interface on the view object that is to be drawn.
dwAspect
[in] How the object is to be represented. Representations include content, an icon, a thumbnail, or a printed document. Valid values are taken from the enumeration DVASPECT. See DVASPECT for more information.
hdcDraw
[in] Device context on which to draw. Cannot be a metafile device context.
lprcBounds
[in] Pointer to a RECT structure specifying the rectangle in which the object should be drawn. This parameter is converted to a RECTL structure and passed to IViewObject::Draw.

Return Values

This function supports the standard return values E_INVALIDARG and E_OUTOFMEMORY, as well as the following:

S_OK
Object was successfully drawn.
OLE_E_BLANK
No data to draw from.
E_ABORT
The draw operation was aborted.
VIEW_E_DRAW
An error occurred in drawing.
OLE_E_INVALIDRECT
The rectangle is invalid.
DV_E_NOIVIEWOBJECT
The object doesn't support the IViewObject interface.

Remarks

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.

QuickInfo

  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.

See Also

IViewObject::Draw