RadioButton Control

Purpose

Creates a control in the current active form, window, or dialog.

Syntax

RadioButton text$, id%, x, y, width, height[, style%]

text$:control text
id%:control identifier
x,y,b,h:iexp
style%:the control styles

Description

The RadioButton statement creates an radio button control. The control is a small circle that has the given text displayed next to it, typically to its right. The control highlights the circle and sends a message to its parent window when the user selects the button. The control removes the highlight and sends a message when the button is next selected.

style Specifies styles for the automatic radio button, which can be a combination of BUTTON-class styles and the following styles: WS_TABSTOP, WS_DISABLED, and WS_GROUP. If you do not specify a style, the default style is BS_RADIOBUTTON | WS_TABSTOP.

Creates a control without an OCX wrapper; so it cannot be handled using properties, methods, and event subs. When used in a form the WM_COMMAND and WM_NOTIFY messages should be handled in the form's _Message sub.

Example

Dialog # 1, 0, 0, 400, 300, "GFA", WS_SYSMENU

RadioButton "Command", 1, 10, 10, 140, 22, BS_DEFPUSHBUTTON

RadioButton "Check Box", 2, 10, 40, 140, 14, BS_AUTOCHECKBOX

RadioButton "Option Button 1", 3, 10, 60, 140, 14, BS_AUTORADIOBUTTON

RadioButton "Option Button 2", 4, 10, 75, 140, 14, BS_AUTORADIOBUTTON

EndDialog

ShowDialog # 1

Do : Sleep : Until Dlg_1 Is Nothing

 

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

If Mess% = WM_COMMAND

Select wParam

Case 1 : Message "Command Button Pressed" & #13#10 & "Option Button 2 Activated"

SetCheck 1, 4, 1 : If Check?(1, 3) Then SetCheck 1, 3, 0

Case 2 : Message "Check Box Clicked" & #13#10 & "Option Button 1 Activated"

SetCheck 1, 3, 1 : If Check?(1, 4) Then SetCheck 1, 4, 0

Case 3, 4 : Message "Option Button" & wParam - 2 & " Clicked"

EndSelect

EndIf

EndSub

 

Sub Dlg_1_Close(Cancel?)

Cancel? = False

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: 22/10/2014 by James Gaite}