Jump to content

Button Problems


Recommended Posts

here is the source

uiCreate("Chronos Tool", 287, 256,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Button_1 = GuiCtrlCreateButton("Server 1", 10, 180, 130, 30)
$Button_2 = GuiCtrlCreateButton("Server 2", 150, 180, 130, 30)
$Input_3 = GuiCtrlCreateInput("text", 20, 100, 250, 70)
$Button_4 = GuiCtrlCreateButton("Update Addons", 10, 60, 120, 30)
$Button_5 = GuiCtrlCreateButton("Go to Forum", 160, 60, 120, 30)
$Button_6 = GuiCtrlCreateButton("Irc Chat", 10, 20, 120, 30)
$Button_7 = GuiCtrlCreateButton("About", 160, 20, 120, 30)
$Button_8 = GuiCtrlCreateButton("Exit", 80, 220, 130, 30)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
    ;;;
    EndSelect
WEnd
Exit
#endregion --- GuiBuilder generated code End ---
While 1
$msg = GUIGetMsg()
Select
Case $msg = $Button_1
Case $msg = $Button_2
Case $msg = $Button_8
    ExitLoop
    
EndSelect

is it any way to make things do actions when i click on the buttons?

Link to comment
Share on other sites

GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

Func CLOSEClicked()
 ;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE,
 ;@GUI_WINHANDLE will be either $mainwindow or $dummywindow
  If @GUI_WINHANDLE = $mainwindow Then 
    MsgBox(0, "GUI Event", "You clicked CLOSE in the main window! Exiting...")
    Exit
  EndIf 
EndFunc

Thanks in advance
Link to comment
Share on other sites

  • Moderators

Here an example:

#include <GuiConstants.au3>

Opt("GuiOnEventMode", 1)

GUICreate("Chronos Tool", 287, 256,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
GUISetOnEvent($GUI_EVENT_CLOSE, "GUI_Close")

$Button_1 = GuiCtrlCreateButton("Server 1", 10, 180, 130, 30)
GUICtrlSetOnEvent(-1, "Do_Something1")
$Button_2 = GuiCtrlCreateButton("Server 2", 150, 180, 130, 30)
GUICtrlSetOnEvent(-1, "Do_Something2")
$Input_3 = GuiCtrlCreateInput("text", 20, 100, 250, 70)
$Button_4 = GuiCtrlCreateButton("Update Addons", 10, 60, 120, 30)
GUICtrlSetOnEvent(-1, "Do_Something3")
$Button_5 = GuiCtrlCreateButton("Go to Forum", 160, 60, 120, 30)
$Button_6 = GuiCtrlCreateButton("Irc Chat", 10, 20, 120, 30)
$Button_7 = GuiCtrlCreateButton("About", 160, 20, 120, 30)
$Button_8 = GuiCtrlCreateButton("Exit", 80, 220, 130, 30)
GUICtrlSetOnEvent(-1, "GUI_Close")

GuiSetState()

While 1
   Sleep(100)
WEnd

Func Do_Something1()
    MsgBox(0, "", "You clicked button_1")
EndFunc

Func Do_Something2()
    MsgBox(0, "", "You clicked button_2")
EndFunc

Func Do_Something3()
    MsgBox(0, "", "You clicked button_4")
EndFunc

Func GUI_Close()
    Exit
EndFunc
Edited by big_daddy
Link to comment
Share on other sites

  • Moderators

i have an other problem with the button thing,

everything works fine for me but if i use

the Opt("GUIOnEventMode", 1) thing i can not close the gui like other programms with (x) close

does anyone know?

thanks

You have to tell it what to do when you use GUIOnEventMode.

Opt("GuiOnEventMode", 1)

GUICreate("Test GUI")
GUISetOnEvent($GUI_EVENT_CLOSE, "GUI_Close")

Func GUI_Close()
    Exit
EndFunc  ;==>GUI_Close
Link to comment
Share on other sites

You have to tell it what to do when you use GUIOnEventMode.

Opt("GuiOnEventMode", 1)

GUICreate("Test GUI")
GUISetOnEvent($GUI_EVENT_CLOSE, "GUI_Close")

Func GUI_Close()
    Exit
EndFunc ;==>GUI_Close

great it works, thanks a lot

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...