Creates a Button control for the GUI.
GUICtrlCreateButton ( "text", left, top [, width [, height [, style = -1 [, exStyle = -1]]]] )
text | The text of the button control. |
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode. |
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode. |
width | [optional] The width of the control (default text autofit in width). |
height | [optional] The height of the control (default text autofit in height). |
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default ( -1) : none. forced styles : $WS_TABSTOP |
exStyle | [optional] Defines the extended style of the control. See Extended Style Table. default ( -1) : WS_EX_WINDOWEDGE |
Success: | the identifier (controlID) of the new control. |
Failure: | 0. |
To set or change information in the control see GUICtrlUpdate...() functions.
A Button control can display an icon or image by using the $BS_ICON or $BS_BITMAP style. Use GUICtrlSetImage() to specify the picture to use.
To combine styles with the default style use BitOR ( $GUI_SS_DEFAULT_BUTTON, newstyle, ... ).
To use the values specified above you must #include <ButtonConstants.au3> in your script.
Default resizing is $GUI_DOCKSIZE
GUICoordMode (Option), GUICtrlUpdate..., GUIGetMsg
#include <GUIConstantsEx.au3>
Example()
Func Example()
; Create a GUI with various controls.
Local $hGUI = GUICreate("Example", 300, 200)
; Create a button control.
Local $idButton_Notepad = GUICtrlCreateButton("Run Notepad", 120, 170, 85, 25)
Local $idButton_Close = GUICtrlCreateButton("Close", 210, 170, 85, 25)
; Display the GUI.
GUISetState(@SW_SHOW, $hGUI)
Local $iPID = 0
; Loop until the user exits.
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE, $idButton_Close
ExitLoop
Case $idButton_Notepad
; Run Notepad with the window maximized.
$iPID = Run("notepad.exe", "", @SW_SHOWMAXIMIZED)
EndSwitch
WEnd
; Delete the previous GUI and all controls.
GUIDelete($hGUI)
; Close the Notepad process using the PID returned by Run.
If $iPID Then ProcessClose($iPID)
EndFunc ;==>Example