Admin Production ni-theme
Current Publication

CanvasClear

LabWindows/CVI

CanvasClear

int CanvasClear (int panelHandle, int controlID, Rect rectangle);

Purpose

Restores the specified rectangular area of a canvas control to the background color of the canvas control.

You can set the background color of the canvas control through the ATTR_PICT_BGCOLOR attribute.

Unlike other canvas drawing operations, CanvasClear can clear the canvas control beyond the canvas clipping rectangle.

Supported Controls

You can use CanvasClear with canvas controls.

Parameters

Input
Name Type Description
panelHandle int Specifier for a particular panel that is currently in memory. You can obtain this handle from functions such as LoadPanel and NewPanel.
controlID int The defined constant, located in the .uir header file, that you assigned to the control in the User Interface Editor, or the ID returned by functions such as NewCtrl and DuplicateCtrl.
rectangle Rect Rect structure that specifyies the location and size of the rectangle to clear.

Use VAL_ENTIRE_OBJECT to specify the entire canvas.

The Rect structure is defined as follows:

typedef struct
   {
   int top;
   int left;
   int height;
   int width;
   } Rect;


You can create a Rect without having to declare a variable by using the following function:

Rect MakeRect (int top, int left, int height, int width);

Example

CanvasClear (panelHandle, controlID, VAL_ENTIRE_OBJECT);

Return Value

Name Type Description
status int Return value indicating whether the function was successful. A negative number indicates that an error occurred.

Additional Information

Library: User Interface Library

Include file: userint.h

LabWindows/CVI compatibility: LabWindows/CVI 4.0 and later

Examples

Refer to the following examples that use the CanvasClear function:

  • apps\iconedit\iconedit.cws

    Open example
  • apps\life\life.cws

    Open example
  • userint\alphablend.cws

    Open example
  • userint\canvas.cws

    Open example
  • userint\canvsbmk.cws

    Open example
  • userint\clipbord.cws

    Open example