Sign in to follow this  
Followers 0

$WM_COMMAND and multiple comboboxes


4 posts in this topic

#1 ·  Posted

I'm trying to use $WM_command to do some creative Auto_complete in a combobox, This works when i Force

$hWndCombo = GUICtrlGetHandle($input[$x][62])

where $input[$x][62] is the handle of the combo.

What I would like is to reuse this code, for multple combo boxes, I can get windows id of the other windows using GUIGetCursorInfo, but not any of the combo boxes, they are always returned as 0.

So How can get the ID of a the Combobox that my cursor is at?

Share this post


Link to post
Share on other sites



#2 ·  Posted

hazed,

_WinAPI_GetFocus returns the control that currently has keyboard input - sounds like just the job. :oops:

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:

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 and edit 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

consolewrite(_WinAPI_GetFocus()&@tab& GUICtrlGetHandle($input[$x][62])& @tab&$ilParam&@lf)

returns when I'm sitting on the control.

0x0012106E 0x00120ACE 0x00120ACE - which to me means that I ilParam = GUICtrlGetHandle($input[$x][62]) and not _WinAPI_GetFocus().

This isn't helping much. to put things into perpective. $input[$x][62] is the handle of the combo in tab($x) which tab is created only if needed and it's an exact duplicate of the previous Tab. (sort of like do you have more, here is page 2,3,4,5...etc)

I guess when I create the comboboxes, I can create an array which maps the what the GUICtrlGetHandle() of each comboboxes in each tab when I create the tab. And then do an arraysearch or something similar to find which combobox I'm dealing with and use different WM_edit_changed() based upon the index.

So

comboarray[$x][1] = GUICtrlGetHandle($input[$x][60])

comboarray[$x][2] = GUICtrlGetHandle($input[$x][62])

comboarray[$x][3] = GUICtrlGetHandle($input[$x][72]).

Since I know the $X,

for $i=1 to 3

if comboarray[$x][$i] = ilparam then exitloop

next

....

Switch $iCode

Case $CBN_CLOSEUP

Case $CBN_KILLFOCUS

WM_validate()

Case $CBN_EDITCHANGE

switch $i

case 1

WM_edit_changed_combo1()

case 2

WM_edit_changed_combo2()

case 3

WM_edit_changed_combo3()

endswitch

EndSwitch

or something like that.... wish I could find a better way.

Share this post


Link to post
Share on other sites

#4 ·  Posted

hazed,

This code distinguishes between the 2 combos using their ControlIDs - why are you looking for handles? :oops:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiComboBox.au3>

Dim $sString = "Hello|world|AutoIt|rules|and|more|some|data"

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

$cCombo_1 = GUICtrlCreateCombo("", 10, 10, 200, 20)
GUICtrlSetData(-1, $sString, "Hello")

$cCombo_2 = GUICtrlCreateCombo("", 10, 100, 200, 20)
GUICtrlSetData(-1, $sString, "Hello")

GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

GUISetState()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    Local $iIDFrom = BitAND($wParam, 0x0000FFFF)
    Local $iCode = BitShift($wParam, 16)

    Switch $iCode
        Case $CBN_EDITCHANGE
            Switch $iIDFrom
                Case $cCombo_1
                    _GUICtrlComboBox_AutoComplete($cCombo_1)
                Case $cCombo_2
                    _GUICtrlComboBox_AutoComplete($cCombo_2)
            EndSwitch
    EndSwitch

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

If you are still having difficulty identifying your combos, please post some code which shows the problem - then we can get a better idea of what is happening. :bye:

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:

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 and edit 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