Skip to content

CreateButton

Narta Xaymar Dirks edited this page Oct 28, 2026 · 6 revisions
BlitzPlus

CreateButton

CreateButton:Int32 text:String, x:Int32, y:Int32, width:Int32, height:Int32, group:Int32, style:Int32=1
Parameter Mode Type Default Description
text In String required Caption of the button.
x In Int32 required Horizontal position inside the group.
y In Int32 required Vertical position inside the group.
width In Int32 required Width of the button.
height In Int32 required Height of the button.
group In Int32 required Window, panel, tabber or canvas that holds it.
style In Int32 1 Kind of button, see the table. Defaults to 1.

Returns: A handle for the button.

Description

Makes a button with a caption. The style picks what it is:

Style Kind
1 Push button, sends $401 when clicked. This is the default
2 Check box, toggles between ticked and not and sends the new state
3 Radio button, ticking one unticks the others in the same group
4 Default button, also fires when Enter is pressed inside its group
5 Cancel button, also fires when Escape is pressed inside its group

Add 65536 to keep the button from following when its group is resized. Radio buttons that share a group belong together, so put sets of them on different panels to keep them apart. Use ButtonState and SetButtonState for check boxes and radio buttons.

Differences

  • Buttons are drawn in the look of the program, not with the controls of the operating system.

Examples

Graphics 320, 240, 32, 2
win = CreateWindow("Buttons", 10, 10, 300, 200, Desktop(), 3)
push = CreateButton("Push", 10, 10, 120, 28, win)
tick = CreateButton("Check box", 10, 50, 140, 24, win, 2)
a    = CreateButton("Radio A", 10, 90, 140, 24, win, 3)
b    = CreateButton("Radio B", 10, 116, 140, 24, win, 3)
SetButtonState a, True
count = 0
Repeat
	e = WaitEvent()
	If e = $401 And EventSource() = push Then count = count + 1 : SetGadgetText push, "Pushed " + count
Until e = $803

Media

CreateButton

Related Commands

CreateComboBox, CreateHtmlView 〔BlitzLLVM〕, CreateLabel, CreateListBox, CreatePanel, CreateProgBar, CreateSlider, CreateTabber

Home · Command Index



Differences
Language Features
BlitzBasic
Blitz3D
BlitzPlus

Clone this wiki locally