Jump to content
Sign in to follow this  
rajeshwaran

On GUI Event Mode, how to identify different event(s) for a control

Recommended Posts

rajeshwaran

I have enabled GUI On Event Mode "Opt("GUIOnEventMode", 1)",

I have also declared a event handler for a Control.

When the handler is called, how to identify the event or events for that particular control ?

For example, I have a listbox, for that I have registered a handler, inside the handler I have to identify the EVENTS (like SELCHANGE, DBL_CLICKED, etc.,)

how to identify ?

Share this post


Link to post
Share on other sites
rajeshwaran

Hi AdmiralAlkex,

My question is not about GUIRegisterMsg(), it is about GUICtrlSetOnEvent()

Share this post


Link to post
Share on other sites
picea892

I'm with the Admiral on this. This can be done more easily with Guiregistermsg()

#include <GuiComboBoxEx.au3>
#include <GuiImageList.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
Opt('MustDeclareVars', 1)


_Main()

Func _Main()
    Global $msg, $hGUI, $hImage, $combobox, $button, $sText
    
    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get Text with Icon", 400, 300)
    $combobox = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    GUISetState()

    $button = GUICtrlCreateButton("Get text", 50, 150, 100, 20)
    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    For $x = 0 To 20
        _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", $x)
    Next
    _GUICtrlComboBoxEx_SetImageList($combobox, $hImage)
    _GUICtrlComboBoxEx_InitStorage($combobox, 150, 300)
    _GUICtrlComboBoxEx_BeginUpdate($combobox)

    For $x = 0 To 20
        _GUICtrlComboBoxEx_AddString($combobox, StringFormat("%03d : Random string", Random(1, 200, 1)), $x, $x)
    Next

    _GUICtrlComboBoxEx_EndUpdate($combobox)
    GuiRegisterMsg($WM_COMMAND,"MY_WM_COMMAND")
Global $fComboFocused = False
    While 1
        $msg = GUIGetMsg()
        Switch $msg
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $button
                _GUICtrlComboBoxEx_GetItemText($combobox, _GUICtrlComboBoxEx_GetCurSel($combobox), $sText)
                MsgBox(4160, "Information", "Edit Text: " & $sText)
        EndSwitch
    WEnd
EndFunc   ;==>_Main

 Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
    Local $nNotifyCode = _HiWord($wParam)
    Local $nID = _LoWord($wParam)
 ; Local $hCtrl = $lParam

    Switch $lParam
    Case $combobox
            Switch $nNotifyCode
            Case $CBN_SETFOCUS
                ConsoleWrite("Focus"&@crlf)
        Case $CBN_KILLFOCUS
            ConsoleWrite("Kill Focus"&@crlf)
        Case $CBN_SELCHANGE
            ConsoleWrite("Selection Changed"&@crlf) 
        Case $CBN_DROPDOWN
            ConsoleWrite("Drop Down"&@crlf)
                
        EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc ;==>MY_WM_COMMAND

Func _HiWord($x)
    Return BitShift($x, 16)
EndFunc ;==>_HiWord

Func _LoWord($x)
    Return BitAND($x, 0xFFFF)
EndFunc ;==>_LoWord

Share this post


Link to post
Share on other sites
AdmiralAlkex

Hi AdmiralAlkex,

My question is not about GUIRegisterMsg(), it is about GUICtrlSetOnEvent()

No, you asked how to identify different events, and I answered that. See the example for whatever control you're using in the "User Defined Function Reference" section in the helpfile.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.