Sign in to follow this  
Followers 0
LurchMan

OnClick of Combobox

4 posts in this topic

Hello Everyone - 

I have a small application that has a combo box that I would like to have it automatically update the list it contains each time the user clicks on the down arrow.  The data comes from a SQLite database.  I have attempted to use WM_NOTIFY with the below code:

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")

    If $iCode = $NM_CLICK Then
        Switch $hWndFrom
            Case GUICtrlGetHandle($inPrs_EmpName)
                ConsoleWrite("you click on Processing Stats Combo" & @CRLF)
            Case GUICtrlGetHandle($inPS_EmpName)
                ConsoleWrite("you click on Phone Stats Combo" & @CRLF)
            Case GUICtrlGetHandle($inPE_EmpName)
                ConsoleWrite("you click on Phone Eval Combo" & @CRLF)
        EndSwitch
    EndIf

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

I can't seem to get any response out of the combobox.  Any Ideas?  Thanks for the help in advance. 


Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

Share this post


Link to post
Share on other sites



LurchMan,

You need to register WM_COMMAND: ;)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <ComboConstants.au3>

$hGUI = GUICreate("Test", 500, 500)

$cCombo_1 = GUICtrlCreateCombo("", 10, 10, 200, 20)
GUICtrlSetData($cCombo_1, "1|2|3|4")
$cCombo_2 = GUICtrlCreateCombo("", 10, 50, 200, 20)
GUICtrlSetData($cCombo_2, "A|B|C|D")
$cCombo_3 = GUICtrlCreateCombo("", 10, 90, 200, 20)
GUICtrlSetData($cCombo_3, "10|20|30|40")

GUISetState()

GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func _WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)

    If _WinAPI_HiWord($wParam) = $CBN_DROPDOWN Then
        Switch _WinAPI_LoWord($wParam)
            Case $cCombo_1
                ConsoleWrite("Combo_1 Dropped" & @CRLF)
            Case $cCombo_2
                ConsoleWrite("Combo_2 Dropped" & @CRLF)
            Case $cCombo_3
                ConsoleWrite("Combo_3 Dropped" & @CRLF)
        EndSwitch
    EndIf

EndFunc
That works for me. :)

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

Melba23, once again you have made my GUI's much more functional! Thank you for the help!


Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

Share this post


Link to post
Share on other sites

LurchMan,

Always a pleasure. :)

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

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