Jump to content

What is -1 for in GuiCtrlSetOnEvent()


cappy2112
 Share

Recommended Posts

THis is right out of the help file

What is the -1 for in the calls to GUICtrlSetOnEvent()

Opt("GUICoordMode",2)

Opt("GUIResizeMode", 1)

Opt("GUIOnEventMode", 1)

$parent1 = GUICreate("Parent1")

GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")

GUISetOnEvent($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

; END

Func OKPressed()

MsgBox(0, "OK Pressed", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE & " CtrlHandle=" & @GUI_CTRLHANDLE)

EndFunc

Func CancelPressed()

MsgBox(0, "Cancel Pressed", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE & " CtrlHandle=" & @GUI_CTRLHANDLE)

EndFunc

Func SpecialEvents()

Select

Case @GUI_CTRLID = $GUI_EVENT_CLOSE

MsgBox(0, "Close Pressed", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE)

Exit

Case @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

Link to comment
Share on other sites

  • Moderators

-1 represents the command/line before.

Example:

$Label = GUICtrlCreateLabel("", 1, 1, 10, 10)
GUICtrlSetData(-1, 'Apple')

Would be the same basically as:

$Label = GUICtrlCreateLabel("", 1, 1, 10, 10)
GUICtrlSetData($Label, 'Apple')

The difference is, the -1 has to be right after the control in question, as using the actual Control ID doesn't.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

-1 represents the command/line before.

Example:

$Label = GUICtrlCreateLabel("", 1, 1, 10, 10)
GUICtrlSetData(-1, 'Apple')

Would be the same basically as:

$Label = GUICtrlCreateLabel("", 1, 1, 10, 10)
GUICtrlSetData($Label, 'Apple')

The difference is, the -1 has to be right after the control in question, as using the actual Control ID doesn't.

THanks again !

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...