Navigation:  thinBasic Modules > UI (User Interface) > CONTROLs >

CONTROL ADD CANVAS

Previous pageReturn to chapter overviewNext page

 

Description

 

Add a static graphic control to a dialog

 

Syntax

 

hndl = CONTROL ADD CANVAS, hwnd, ctrlID, txt, xPos, yPos, Width, Height [, [Style] [, [ExStyle]]] [[,] CALL CallBack]

 

Returns

 

Number

Control window handler.

 

Parameters

 

Name

Type

Optional

Meaning

hwnd

Number

No

Handle of the dialog containing the control

ctrlID

Number

No

Control identifier

txt

String

No

A text expression representing the text you want to assign to the control.

xPos

Number

No

Horizontal position of the control inside the dialog

yPos

Number

No

Vertical position of the control inside the dialog

Width

Number

No

Control width

Height

Number

No

Control height

Style

Number

Yes

Optional primary style of the canvas control.

This value can be a combination of the values below, combined together with the OR operator to form a bitmask. If style is omitted, the default combination is:

%WS_CHILD OR %WS_VISIBLE OR %SS_OWNERDRAW.

 

%SS_NOTIFY

Send %STN_CLICKED and %STN_DBLCLK notification messages to the Callback Function when the user clicks or double-clicks the control.

%SS_SUNKEN

Draw a half-sunken border around the graphic control.

%WS_BORDER

Add a thin line border around the graphic control.

%WS_DLGFRAME

Create a graphic control that has a border of the style typically used with dialog boxes.

ExStyle

Number

Yes

Optional extended style of the Canvas control.

This value can be a combination of the values below, combined together with the OR operator to form a bitmask. If exstyle is omitted, there is no default extended style.

 

%WS_EX_CLIENTEDGE

Apply a sunken edge border to the control.

%WS_EX_STATICEDGE

Apply a three-dimensional border style to the control (intended to be used for items that do not accept user input).

CallBack

Function

Yes

Optional name of a Callback Function that receives all %WM_COMMAND and %WM_NOTIFY messages for the control.

 

If a callback for the control is not designated, you must create a dialog Callback Function to process messages from your control.

 

If the Callback Function processes a message, it should return %TRUE (non-zero) to prevent the message being passed unnecessarily to the dialog callback (if one exists). The dialog callback should also return %TRUE if the notification message is processed by that Callback Function.

 

Remarks

 

A canvas control is typically used with graphic statements to draw graphs, pictures, text, etc. After you create a graphic control, you must use Canvas_Attach to choose it for use with other statements and functions.

A canvas control will only send notification messages to a callback if the %SS_NOTIFY style is used. Notification messages are sent to the callback function with CBMSG = %WM_COMMAND, CBCTL holding the ID of the control, and CBCTLMSG holding one of the following values:

 

%STN_CLICKED

Sent when the user clicks a mouse button on the graphic control (unless the image control has been disabled).

%STN_DBLCLK

Sent when the user double-clicks on a graphic control (unless the control has been disabled).

%STN_DISABLE

Sent when a graphic control has been disabled.

%STN_ENABLE

Sent when a graphic control has been enabled.

 

Restrictions

 

See also

 

Examples