Programming Reference: ODWin32Canvas

# Programming Reference

## ODWin32Canvas

Class definition file | WinPCanv.idl
Class C++ Binding | WinPCanv.xh

Class hierarchy

    SOMObject
       ODObject
          ODPlatformCanvas
             ODWin32Canvas

Description | ODWin32Canvas is a Windows-specific class that serves as a platform parent class for other classes used to encapsulate Windows drawing contexts. The ODWin32Canvas is derived from ODPlatformCanvas and wraps a device context (DC). It can be instantiated directly to access the CreateConcreteCanvas factory method for creating instances of ODWin32StandardCanvas and ODWin32WindowCanvas. These two classes override nearly all of the methods of ODWin32Canvas. ODWin32StandardCanvas initializes offscreen static, offscreen dynamic, and onscreen static canvases. ODWin32WindowCanvas initializes onscreen dynamic canvases. Because ODWin32StandardCanvas and ODWin32WindowCanvas do not introduce any new methods, objects of both classes can be referred to using a pointer to an ODWin32Canvas.

Methods

The methods defined for the ODWin32Canvas class include:

- GetDC (Windows)
- GetMetafileExtent (Windows)
- GetWindow (Windows)
- InitPlatformCanvas (Windows)
- InitPlatformWindowCanvas (Windows)
- ReleaseDC (Windows)
- SetMetafileExtent (Windows)

Overridden methods

The methods overridden by the ODWin32Canvas class include:

- ODPlatformCanvas::CreateConcreteCanvas
- ODPlatformCanvas::GetPlatformCanvasType
- ODPlatformCanvas::GetSystemType
- ODPlatformCanvas::HasWindow
- ODPlatformCanvas::IsInitialized

### GetDC (Windows)

This method returns a handle to the device context (DC) of this platform canvas.

Signature

    HDC *GetDC ()

Parameters

None.

Returns

rv (HDC) - returns

  An handle to the DC of the platform canvas.

Remarks

This method must be overridden by a subclass and will return a kODErrInvalidObjectType if this platform canvas is an ODWin32Canvas. If this platform canvas is a subclass and is initialized, then the handle to the DC will be returned. If this platform canvas is an ODWin32WindowCanvas, then you must release the DC using ReleaseDC when you finish drawing.

Exception Handling

kODErrInvalidObjectType | This method is not valid on this object.

### GetMetafileExtent (Windows)

This method indicates whether this platform canvas has a metafile extent and, if so, the x and y values.

Signature

    ODBoolean GetMetafileExtent (SIZE *metafileExtent)

Parameters

metafileExtent (SIZE *) - input

The x and y extents of the metafile.

Returns

rv (ODBoolean) - returns

  This method returns the following values:

  kODTrue | This platform canvas has a metafile extent.
  kODFalse | This platform canvas does not have a metafile extent.

Remarks

This method must be overridden by a subclass and returns a kODErrInvalidObjectType if this platform canvas is an ODWin32Canvas.

Exception Handling

kODErrInvalidObjectType | This method is not valid on this object.

### GetWindow (Windows)

This method returns a reference to the window associated with this platform canvas.

Signature

    HWND GetWindow ()

Parameters

None.

Returns

rv (HWND) - returns

  A reference to the window handle.

Remarks

This method must be overridden by a subclass and returns a kODErrInvalidObjectType if this platform canvas is an ODWin32Canvas. If this platform canvas is an ODWin32WindowCanvas and is initialized, then it returns the window associated with this platform canvas.

Exception Handling

kODErrInvalidObjectType | This method is not valid on this object.

### InitPlatformCanvas (Windows)

This method initializes the platform canvas using a handle to a device context.

Signature

    void InitPlatformCanvas (HDC hdc)

Parameters

hdc (HDC) - input

  A handle to a valid device context.

Returns

None.

Remarks

This method must be overridden by a subclass. This method returns kODErrInvalidObjectType if this platform canvas is an ODWin32Canvas.

Exception Handling

kODErrInvalidObjectType | This method is not valid on this object.

### InitPlatformWindowCanvas (Windows)

This method initializes the platform canvas using a handle to a window.

Signature

    void InitPlatformWindowCanvas (HWND hwnd)

Parameters

hwnd (HWND) - input

  A handle to a valid device context.

Returns

None.

Remarks

This method must be overridden by a subclass. This method returns kODErrInvalidObjectType if this platform canvas is an ODWin32Canvas.

Exception Handling

kODErrInvalidObjectType | This method is not valid on this object.

### ReleaseDC (Windows)

This method decrements the reference count and releases the device context when the reference count reaches zero.

Signature

    void ReleaseDC ()

Parameters

None.

Returns

None.

Remarks

This method must be overridden by a subclass and returns a kODErrInvalidObjectType if this platform canvas is an ODWin32Canvas. If this platform canvas is an ODWin32WindowCanvas and is initialized, then it decrements the reference count. When the reference count reaches zero, the device context is released.

Exception Handling

kODErrInvalidObjectType | This method is not valid on this object.

### SetMetafileExtent (Windows)

This method sets the metafile extents for this platform canvas.

Signature

    void SetMetafileExtent (SIZE *metafileExtent)

Parameters

metafileExtent (SIZE *) - input

  The x and y extents of the metafile.

Returns

None.

Remarks

This method must be overridden by a subclass and returns a kODErrInvalidObjectType if this platform canvas is an ODWin32Canvas.

Exception Handling

kODErrInvalidObjectType | This method is not valid on this object.

[ Top | Previous | Next | Contents | Index | Documentation Homepage ]