Jump to content
Sign in to follow this  

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

Recommended Posts

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

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)


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)

    $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)
    _GUICtrlComboBoxEx_SetImageList($combobox, $hImage)
    _GUICtrlComboBoxEx_InitStorage($combobox, 150, 300)

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

Global $fComboFocused = False
    While 1
        $msg = GUIGetMsg()
        Switch $msg
            Case $GUI_EVENT_CLOSE
            Case $button
                _GUICtrlComboBoxEx_GetItemText($combobox, _GUICtrlComboBoxEx_GetCurSel($combobox), $sText)
                MsgBox(4160, "Information", "Edit Text: " & $sText)
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
        Case $CBN_KILLFOCUS
            ConsoleWrite("Kill Focus"&@crlf)
        Case $CBN_SELCHANGE
            ConsoleWrite("Selection Changed"&@crlf) 
        Case $CBN_DROPDOWN
            ConsoleWrite("Drop Down"&@crlf)

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

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...