OleDraw (Windows Embedded CE 6.0)

1/6/2010

This helper function provides a convenient way to draw objects by encapsulating the IViewObject::Draw method and other related maintenance functions for the drawing rectangle.

Syntax

WINOLEAPIOleDraw(
  IUnknown* pUnk,
  DWORD dwAspect,
  HDC hdcDraw,
  LPCRECT  lprcBounds
);

Parameters

  • pUnk
    [in] Pointer to the IUnknown interface on the view object that is to be drawn.
  • dwAspect
    [in] Specifies how the object is to be represented.

    Representations include the following:

    • Content
    • An icon
    • A thumbnail
    • A printed document

    Valid values are taken from the enumeration DVASPECT. For more information, see DVASPECT.

  • hdcDraw
    [in] Handle to the device context (DC) on which to draw.

    Cannot be a metafile device context.

  • lprcBounds
    [in] Long pointer to a RECT structure specifying the rectangle where the object should be drawn.

    This parameter is converted to a RECTL structure and passed to IViewObject::Draw.

Return Value

The following HRESULT values can be returned.

Value Description

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 does not support the IViewObject interface.

E_INVALIDARG

The function has failed.

E_OUTOFMEMORY

The function has failed.

Remarks

Passing invalid (and under some circumstances NULL) pointers into this function causes an unexpected termination of the application.

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.

To determine whether the platform supports this function, see Determining Supported COM APIs.

Requirements

Header ole2.h
Library ole32.lib
Windows Embedded CE Windows CE 2.0 and later

See Also

Reference

OLE Functions
Automation Functions
IViewObject::Draw
DVASPECT
IUnknown
DVASPECT
IViewObject
IUnknown::QueryInterface

Concepts

Determining Supported COM APIs

Other Resources

RECTL
RECT