Sign in to follow this  
Followers 0
atzoref

GUICtrlSetOnEvent Problem

3 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



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


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks on your help and for your Tips :)

It's OK now

Edited by atzoref

Share this post


Link to post
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
Sign in to follow this  
Followers 0