Jump to content

making button work


Recommended Posts

here is mu GUI

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 334, 206, 192, 124)
$Button1 = GUICtrlCreateButton("Button1", 16, 40, 129, 49, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Button2", 176, 40, 145, 49, $WS_GROUP)
GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

how can i get my button to work?

want to add simple stuff like

MsgBox(4096,"Test", "hello")

MsgBox(4096,"Test", "Bye")

in each button

thanks

Link to comment
Share on other sites

All you do is add the case for the control

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 334, 206, 192, 124)
$Button1 = GUICtrlCreateButton("Button1", 16, 40, 129, 49, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Button2", 176, 40, 145, 49, $WS_GROUP)
GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            MsgBox(4096,"Test", "hello")
        Case $Button2
            MsgBox(4096,"Test", "Bye")
    EndSwitch
WEnd
Link to comment
Share on other sites

I usually prefer to set GuiOnEventMode to 1 and use GuiCtrlSetOnEvent.

The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Link to comment
Share on other sites

onevent!!! YEAH!!

lol i love that... THOUGH i sometimes add Guigetmsg and setonevent 0 in certain functions to clean it up... but overall i prefer onevent

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