Jump to content

Problem clearing(disabling) GUICtrlSetOnEvent


TheOrignl
 Share

Recommended Posts

The code below represents manipulation of a CheckBox control via its own events as well as surrounding controls. I'm having problems understanding whether I'm using GUICtrlSetOnEvent correctly to disable an event on controls, near the bottom after the If statement.

Func check_tog()
    Select
        Case ((@GUI_CTRLID == $chk_med) And (GUICtrlRead($chk_med) = $GUI_CHECKED))
            GUICtrlSetData($chk_med, "Yes")
            GUICtrlSetFont($chk_med, 8, 800, 0, "MS Sans Serif")
            GUICtrlSetColor($chk_med, $COLOR_GREEN)
        Case ((@GUI_CTRLID == $chk_med) And (GUICtrlRead($chk_med) = $GUI_UNCHECKED))
            GUICtrlSetData($chk_med, "No")
            GUICtrlSetFont($chk_med, 8, 800, 0, "MS Sans Serif")
            GUICtrlSetColor($chk_med, $COLOR_RED)
            GUICtrlSetData($lbl_med_path, $infile)
        Case (GUICtrlRead($chk_med) = $GUI_CHECKED)
            GUICtrlSetState($chk_med, $GUI_UNCHECKED)
            GUICtrlSetData($chk_med, "No")
            GUICtrlSetFont($chk_med, 8, 800, 0, "MS Sans Serif")
            GUICtrlSetColor($chk_med, $COLOR_RED)
            GUICtrlSetData($lbl_med_path, $infile)
        Case (GUICtrlRead($chk_med) = $GUI_UNCHECKED)
            GUICtrlSetState($chk_med, $GUI_CHECKED)
            GUICtrlSetData($chk_med, "Yes")
            GUICtrlSetFont($chk_med, 8, 800, 0, "MS Sans Serif")
            GUICtrlSetColor($chk_med, $COLOR_GREEN)
    EndSelect
    if (GUICtrlRead($chk_med) = $GUI_CHECKED) Then
        GUICtrlSetOnEvent($btn_med, "");<==???
        GUICtrlSetOnEvent($lbl_med_path, "");<==???
        Call("btn_browse")
    Else
        GUICtrlSetOnEvent($btn_med, "group_set")
        GUICtrlSetOnEvent($lbl_med_path, "group_set")
    EndIf
EndFunc
Edited by TheOrignl

Managing the complexities of our daily lives is always our own responsibility; Allowing God to help us and accepting His guidance is our choice. The best choice!

Link to comment
Share on other sites

The code below represents manipulation of a CheckBox control via its own events as well as surrounding controls. I'm having problems understanding whether I'm using GUICtrlSetOnEvent correctly to disable an event on controls, near the bottom after the If statement.

Func check_tog()
    Select
        Case ((@GUI_CTRLID == $chk_med) And (GUICtrlRead($chk_med) = $GUI_CHECKED))
            GUICtrlSetData($chk_med, "Yes")
            GUICtrlSetFont($chk_med, 8, 800, 0, "MS Sans Serif")
            GUICtrlSetColor($chk_med, $COLOR_GREEN)
        Case ((@GUI_CTRLID == $chk_med) And (GUICtrlRead($chk_med) = $GUI_UNCHECKED))
            GUICtrlSetData($chk_med, "No")
            GUICtrlSetFont($chk_med, 8, 800, 0, "MS Sans Serif")
            GUICtrlSetColor($chk_med, $COLOR_RED)
            GUICtrlSetData($lbl_med_path, $infile)
        Case (GUICtrlRead($chk_med) = $GUI_CHECKED)
            GUICtrlSetState($chk_med, $GUI_UNCHECKED)
            GUICtrlSetData($chk_med, "No")
            GUICtrlSetFont($chk_med, 8, 800, 0, "MS Sans Serif")
            GUICtrlSetColor($chk_med, $COLOR_RED)
            GUICtrlSetData($lbl_med_path, $infile)
        Case (GUICtrlRead($chk_med) = $GUI_UNCHECKED)
            GUICtrlSetState($chk_med, $GUI_CHECKED)
            GUICtrlSetData($chk_med, "Yes")
            GUICtrlSetFont($chk_med, 8, 800, 0, "MS Sans Serif")
            GUICtrlSetColor($chk_med, $COLOR_GREEN)
    EndSelect
    if (GUICtrlRead($chk_med) = $GUI_CHECKED) Then
        GUICtrlSetOnEvent($btn_med, "");<==???
        GUICtrlSetOnEvent($lbl_med_path, "");<==???
        Call("btn_browse")
    Else
        GUICtrlSetOnEvent($btn_med, "group_set")
        GUICtrlSetOnEvent($lbl_med_path, "group_set")
    EndIf
EndFunc
That's ok, it's what the help says you can do.
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

That's ok, it's what the help says you can do.

Thank you for the confirmation. But the problem is the implementation is not working in my code, neither above or below the Call("btn_browse") or outside the If statement. Anyone ever tried to clear events on controls dynamically?

Managing the complexities of our daily lives is always our own responsibility; Allowing God to help us and accepting His guidance is our choice. The best choice!

Link to comment
Share on other sites

Thank you for the confirmation. But the problem is the implementation is not working in my code, neither above or below the Call("btn_browse") or outside the If statement. Anyone ever tried to clear events on controls dynamically?

I don't see a problem.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $word = 'camel'
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=C:\temp\Form1.kxf
$Form1 = GUICreate("Dialog", 368, 196, 321, 254)
GUISetIcon("D:\004.ico")
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1Maximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore")
$Button1 = GUICtrlCreateButton("say ?", 134, 35, 75, 25, 0)
GUICtrlSetOnEvent(-1, "Button1Click")
$Button2 = GUICtrlCreateButton("? = cat", 133, 68, 75, 25, 0)
GUICtrlSetOnEvent(-1, "Button2Click")
$Button3 = GUICtrlCreateButton("? = dog", 133, 100, 75, 25, 0)
GUICtrlSetOnEvent(-1, "Button3Click")
$Button4 = GUICtrlCreateButton("do nothing", 133, 133, 75, 25, 0)
GUICtrlSetOnEvent(-1, "Button4Click")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    Sleep(100)
WEnd

Func Button1Click()
    MsgBox(262144, "? is", 'camel')
EndFunc  ;==>Button1Click
Func Button2Click()
    GUICtrlSetOnEvent($Button1, "saycat")
EndFunc  ;==>Button2Click
Func Button3Click()
    GUICtrlSetOnEvent($Button1, "saydog")
EndFunc  ;==>Button3Click

Func Button4Click()
    GUICtrlSetOnEvent($Button1, "")
EndFunc  ;==>Button4Click

Func Form1Close()
    Exit
EndFunc  ;==>Form1Close
Func Form1Maximize()

EndFunc  ;==>Form1Maximize
Func Form1Minimize()

EndFunc  ;==>Form1Minimize
Func Form1Restore()

EndFunc  ;==>Form1Restore
Func saycat()
    MsgBox(262144, "? is", 'cat')
    
EndFunc  ;==>saycat

Func saydog()
    MsgBox(262144, "? is", 'dog')
    
EndFunc  ;==>saydog
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Never mind. I'll just slap myself. The only control I tested, of two controls I was clearing, was the one I wasn't making equal to the temporary variables used. Should have pasted the full code for your eyes, mne sure weren't seeing the problem. :)

Managing the complexities of our daily lives is always our own responsibility; Allowing God to help us and accepting His guidance is our choice. The best choice!

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