Jump to content

GUICtrlSetOnEvent Problem


atzoref
 Share

Recommended Posts

Hi,

I have main GUI window which also running a function which open a kind of popup GUI window

The problem is that on the popup GUI, GUICtrlSetOnEvent not running the specific function

The button "Cancel" not doing nothing, but the alhought $GUI_EVENT_CLOSE works works good

Why is that?

Here is the code of the popup GUI:

Func ItemSettings()

$frSettingsWindow = GUICreate("A", 491, 275, -1, -1)
$btnApply = GUICtrlCreateButton("Apply", 320, 224, 75, 25)
$btnCancel = GUICtrlCreateButton("Cancel", 400, 224, 75, 25)
$edNumOfLoops = GUICtrlCreateInput("1", 128, 32, 121, 21)
$chbResetScanner = GUICtrlCreateCheckbox("Reset Scanner", 32, 56, 97, 17)
$lLoops = GUICtrlCreateLabel("Number Of Loops:", 32, 32, 90, 17)
AutoItSetOption("GUIOnEventMode", 1)     ;Enable OnEvent functions notifications.ventMode", 1)
GUISetOnEvent($GUI_EVENT_CLOSE, "closePopup", $frSettingsWindow)
;GUISetOnEvent($btnApply, "ChangeName", $frSettingsWindow)
GUISetOnEvent($btnCancel, "Temp", $frSettingsWindow)
GUISetState(@SW_SHOW, $frSettingsWindow)
EndFunc

Func closePopup()
  GUIDelete ( @GUI_WinHandle )
EndFunc

Func Temp()
  MsgBox(0,"","TT")
EndFunc
Edited by atzoref
Link to comment
Share on other sites

  • Moderators

atzoref,

Firstly, learn to set your code out in a more logical way - like putting the Opt to set OnEvent mode at the top. Take a look at the example below. :)

I also suggest that you put the *SetOnEvent lines immediately after the item to which they refer. That way you will find it easier to see the error of using GUISetOnEvent($btnCancel...) rather than GUICtrlSetOnEvent($btnCancel...). ;)

This works for me:

#include <GUIConstantsEx.au3>

AutoItSetOption("GUIOnEventMode", 1) ;Enable OnEvent functions notifications.ventMode", 1)

ItemSettings()

While 1
    Sleep(10)
WEnd

Func ItemSettings()

    $frSettingsWindow = GUICreate("A", 491, 275, -1, -1)
    GUISetOnEvent($GUI_EVENT_CLOSE, "closePopup")

    $btnApply = GUICtrlCreateButton("Apply", 320, 224, 75, 25)
    $btnCancel = GUICtrlCreateButton("Cancel", 400, 224, 75, 25)
    GUICtrlSetOnEvent($btnCancel, "Temp")
    $edNumOfLoops = GUICtrlCreateInput("1", 128, 32, 121, 21)
    $chbResetScanner = GUICtrlCreateCheckbox("Reset Scanner", 32, 56, 97, 17)
    $lLoops = GUICtrlCreateLabel("Number Of Loops:", 32, 32, 90, 17)


    GUISetState(@SW_SHOW, $frSettingsWindow)
EndFunc   ;==>ItemSettings

Func closePopup()
    GUIDelete(@GUI_WinHandle)
EndFunc   ;==>closePopup

Func Temp()
    MsgBox(0, "", "TT")
EndFunc   ;==>Temp

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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