GUISetState [flag [, winhandle]] Parameters flag [optional] @SW_SHOW = Shows a previously hidden window default @SW_HIDE = Hide window @SW_MINIMIZE = Minimize window @SW_MAXIMIZE = Ma
Trang 1GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")
$ok1 = GUICtrlCreateButton("OK", 10, 30, 50)
GUICtrlSetOnEvent(-1, "OKPressed")
$cancel1 = GUICtrlCreateButton("Cancel", 0, -1)
GUICtrlSetOnEvent(-1, "CancelPressed")
GUISetState(@SW_SHOW)
; Just idle around
While 1
Sleep(10)
WEnd
EndFunc ;==>Example
Func OKPressed()
MsgBox(0, "OK Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" &
@GUI_WinHandle & " CtrlHandle=" & @GUI_CtrlHandle)
EndFunc ;==>OKPressed
Func CancelPressed()
MsgBox(0, "Cancel Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" &
@GUI_WinHandle & " CtrlHandle=" & @GUI_CtrlHandle)
EndFunc ;==>CancelPressed
Func SpecialEvents()
Select
Case @GUI_CtrlId = $GUI_EVENT_CLOSE
MsgBox(0, "Close Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" &
@GUI_WinHandle)
Exit
Trang 2Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE
MsgBox(0, "Window Minimized", "ID=" & @GUI_CtrlId & "
WinHandle=" & @GUI_WinHandle)
Case @GUI_CtrlId = $GUI_EVENT_RESTORE
MsgBox(0, "Window Restored", "ID=" & @GUI_CtrlId & " WinHandle="
& @GUI_WinHandle)
EndSelect
EndFunc ;==>SpecialEvents
Function Reference
GUISetState
Changes the state of a GUI window
GUISetState ( [flag [, winhandle]] )
Parameters
flag
[optional]
@SW_SHOW = Shows a previously hidden window (default)
@SW_HIDE = Hide window
@SW_MINIMIZE = Minimize window
@SW_MAXIMIZE = Maximize window
@SW_RESTORE = Undoes a window minimization
@SW_DISABLE = Disables the window
@SW_ENABLE = Enables the window
@SW_LOCK = Lock the window to avoid repainting
@SW_UNLOCK = Unlock windows to allow painting
winhandle [optional] Windows handle as returned by GUICreate (default is the
previously used window)
Trang 3
Return Value
Success: Returns 1
Failure: Returns 0
Remarks
When windows are created they are initially hidden so you must use this function
to display them (@SW_SHOW)
Only one window can be locked with @SW_LOCK Any other @SW_LOCK will lock the requested window
@SW_UNLOCK just ignored the "winhandle" to unlock any locked window
Related
GUICreate
Example
#include <GUIConstantsEx.au3>
Opt('MustDeclareVars', 1)
Example()
Func Example()
Local $msg
GUICreate("My GUI") ; start the definition
GUISetState() ; will display an empty dialog box
; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Trang 4
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
EndFunc ;==>Example
bFunction Reference
GUISetStyle
Changes the styles of a GUI window
GUISetStyle ( Style [,ExStyle [, winhandle]] )
Parameters
style
defines the style of the window See GUI Control Styles Appendix Use -1 to leave it unchanged
exStyle
[optional] defines the extended style of the window See the Extended Style Table below -1 is the default
Use -1 to leave it unchanged
winhandle [optional] Windows handle as returned by GUICreate (default is the
previously used window)
Return Value
Success: Returns 1
Failure: Returns 0
Remarks
No checking is done on style value, neither non interaction with already defined control It is the designer responsability to take care of this compatibility
Trang 5Related
GUICreate, GUIGetStyle
Example
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt('MustDeclareVars', 1)
Example()
Func Example()
Local $NewStyle = False, $hWnd, $Style, $Msg
$hWnd = GUICreate("Gui Style", 260, 100)
$Style = GUICtrlCreateButton("Set Style", 45, 50, 150, 20)
GUISetState()
While 1
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
Exit
Case $Style
If Not $NewStyle Then
GUISetStyle(BitOR($WS_POPUPWINDOW,
$WS_THICKFRAME), BitOR($WS_EX_CLIENTEDGE,
$WS_EX_TOOLWINDOW))
GUICtrlSetData($Style, 'Undo Style')
$NewStyle = True
Else
GUISetStyle(BitOR($WS_MINIMIZEBOX, $WS_CAPTION,
$WS_POPUP, $WS_SYSMENU), 0)
Trang 6GUICtrlSetData($Style, 'Set Style') $NewStyle = False
EndIf
Case Else