CheckBox Control

Purpose

Creates a checkbox.

Syntax

CheckBox text$, ID%, x%, y%, w%, h%[,style%]

Description

A CheckBox is a rectangle which has diagonals drawn in it when clicked on with the mouse. The text specified in text$ is displayed right justified next to the rectangle. A CheckBox can contain the WS_TABSTOP and WS_GROUP style elements.

Messages from the CheckBox are handled in the _Message event sub of the parent

Example

Dlg 3D On

Local style1%, style2%, x%

style1% = BS_AUTOCHECKBOX | WS_TABSTOP | WS_BORDER

style2% = BS_GROUPBOX | WS_GROUP

Dialog # 1, 10, 10, 310, 170, "Dialog 2", WS_SYSMENU

CheckBox "Check1", 11, 50, 50, 80, 30, style1%

CheckBox "Check2", 12, 50, 100, 80, 30, style1%

GroupBox "Test field1", 13, 10, 10, 140, 130, style2%

AutoCheckBox "Check3", 13, 170, 50, 80, 30, style1%

AutoCheckBox "Check4", 14, 170, 100, 80, 30, style1%

GroupBox "Test field2", 23, 160, 10, 140, 130, style2%

EndDialog

SetCheck 1, 11, 1

SetCheck 1, 14, 1

ShowDialog # 1

Do

Sleep

Until Me Is Nothing

Dlg 3D Off

 

Sub Dlg_1_Close(Cancel?)

Cancel? = False ' don't cancel close

EndSub

 

Sub Dlg_1_Message(hWnd%, Mess%, wParam%, lParam%)

Switch Mess

Case WM_COMMAND

Trace wParam

If wParam >= 11 And wParam <= 14

If Check?(1, wParam) Then Message "Checkbox" & wParam - 10 & " Checked"

If Check?(1, wParam) = 0 Then Message "Checkbox" & wParam - 10 & " Unchecked"

EndIf

EndSwitch

EndSub

Remarks

This command is particular useful for a dialog box in a GLL, because a GLL doesn't support OCX controls.

With the general Control statement any control type can be created.

See Also

Control, AnimateCtrl, AutoCheckBox, AutoRadioButton, CheckBox, ComboBox, CText, Dialog, DefPushButton, EditText, GroupBox, HeaderCtrl, ListBox, ListViewCtrl, LText, ProgressCtrl, PushButton, RadioButton, RichEditCtrl, RText, ScrollBar, StatusCtrl, TabCtrl, ToolBarCtrl, TrackBarCtrl, TreeViewCtrl, UpDownCtrl

{Created by Sjouke Hamstra; Last updated: 24/09/2014 by James Gaite}