PushButton Control

Purpose

Creates a pushbutton with width, height and upper left corner is at the coordinates specified

Syntax

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

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

Description

A PushButton contains the text specified in text$ within the rectangle. When a mouse click occurs within a PushButton, it sends a message to its window. PUSHBUTTONs can contain the WS_TABSTOP, WS_DISABLED, and WS_GROUP style elements.

BS_PUSHBUTTON ($0000) - A button defined in this way sends a message to the parent window when clicked on.

BS_DEFPUSHBUTTON ($0001) - defines a button which is preselected as default (thick border; selection by pressing the Return key, mostly the OK button). A message is sent to the parent window when a click occurs on the button or the Return key is pressed.

BS_CHECKBOX ($0002) - a small rectangular button which can be marked as checked by clicking on it.

BS_AUTOCHECKBOX ($0003) - identical to BS_CHECKBOX. However, when clicked on it changes its status.

BS_RADIOBUTTON ($0004) - specifies a small round button which can be selected by clicking. Normally several radio buttons are grouped together and can be selected exclusively. Selecting one of them inactivates the remaining buttons in the same group.

BS_3STATE ($0005) - identical to BS_CHECKBOX. However, it also offers the possibility of displaying the button as gray. The graying means that button can't be selected.

BS_AUTO3STATE ($0006) - identical to BS_3STATE. However, it changes its status when clicked on.

BS_GROUPBOX ($0007) - specifies a rectangle inside which several buttons (such as radio buttons) can be grouped.

BS_AUTORADIOBUTTON $0009) - identical to BS_RADIOBUTTON. However, when activated it is automatically marked as checked and all other buttons in the same group are cleared.

BS_OWNERDRAW ($000B) - specifies a rectangle whose display is performed by a special procedure.

BS_LEFTTEXT ($0020) - displays the text left justified for check boxes and radio buttons.

In GFA-BASIC you can easily modify the appearance of buttons using the BS_OWNERDRAW style. The first character of the buttons text (given in the Button-Command or with _Win$()= or a system- function) determines the appearance of the button.

If it is a digit, a minus sign, or a hash sign, then the string (ignoring the hash) is taken as the decimal Handle of a bitmap. This bitmap is then used to draw the button. optionally a second bitmap handle after a comma can be given to display the button as selected. The usual windows shortcuts (as &A) can be given additionally, but are not displayed.

A leading "S" gives a softer three dimensional appearance, without the usual black border. This can be used to group buttons very close (as in the GFA-BASIC editor). The contents of the buttons title starting from the second character is diaplyed as usual.

A leading "R" displays a rounded button.

Example

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

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

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

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

PushButton "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

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