Jump to content

dialog box won't respond to OK button presses


Recommended Posts

my dialog box won't respond to OK button presses. what's wrong with this code?

#include <GUIConstants.au3>
#include <Date.au3>

Opt("GUIOnEventMode", 1) ; Change to OnEvent mode 
$mainwindow = GUICreate("Enter labels", 200, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("Please enter any other required label and click OK", 30, 10, 100, 80)
$okbutton = GUICtrlCreateButton("OK", 70, 65, 60)
GUICtrlSetOnEvent($okbutton, "OKButton")
GUISetState(@SW_SHOW)

While 1
  Sleep(1000) ; Idle around
WEnd





Func OKButton()
 ;Note: at this point @GUI_CTRLID would equal $okbutton,
 ;and @GUI_WINHANDLE would equal $mainwindow
  MsgBox(0, "GUI Event", "You pressed OK!")

EndFunc

Func CLOSEClicked()
 ;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE, 
 ;and @GUI_WINHANDLE would equal $mainwindow 
  MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...")
  Exit
EndFunc
Link to comment
Share on other sites

This portion is wrong...

While 1
  Sleep(1000) ; Idle around
WEnd
oÝ÷ Ø×vËh$)¶¬jëh×6
 While 1
        $msg = GUIGetMsg()
        Select

    Case $msg = $okbutton
            Exit
        EndSelect
    WEnd
Edited by joshiieeii
Link to comment
Share on other sites

ok i think i figured it out myself. i created a label that covered the button. but that's dumb. buttons should always take precedent and be in FRONT of labels. because if the label was actually in front of the button, it should have visually covered bits of the button to indicate this and thus would visually indicate that the button wouldn't work properly but as it is, it shows the button in FRONT, but focus-wise is BEHIND the label.

Link to comment
Share on other sites

This portion is wrong...

While 1
  Sleep(1000) ; Idle around
WEnd
oÝ÷ Ø×vËh$)¶¬jëh×6
 While 1
        $msg = GUIGetMsg()
        Select

    Case $msg = $okbutton
            Exit
        EndSelect
    WEnd
the code is valid, joshiieeii. i extracted it from AutoIt's help file. but like i said, i figured out what was wrong. it was the label hiding the button.
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...