Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

$WM_COMMAND and multiple comboboxes

$WM_COMMAND combobox

  • Please log in to reply
3 replies to this topic

#1 hazed

hazed

    Seeker

  • Active Members
  • 46 posts

Posted 09 March 2012 - 03:32 PM

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?







#2 Melba23

Melba23

    I'm old - what's your excuse?

  • Moderators
  • 19,879 posts

Posted 09 March 2012 - 03:50 PM

hazed,

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

M23
StringSize - Automatically size controls to fit text                                                               ExtMsgBox - A user customisable replacement for MsgBox
Toast - Small GUIs which pop out of the Systray                                                                Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command                                   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI                                      NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure      Notify - Small notifications on the edge of the display
Date_Time_Convert - Easily convert date/time formats, including the language               GUIListViewEx - Insert, delete, move, drag, sort and edit ListView items

#3 hazed

hazed

    Seeker

  • Active Members
  • 46 posts

Posted 09 March 2012 - 09:32 PM

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.

#4 Melba23

Melba23

    I'm old - what's your excuse?

  • Moderators
  • 19,879 posts

Posted 09 March 2012 - 10:00 PM

hazed,

This code distinguishes between the 2 combos using their ControlIDs - why are you looking for handles? :oops:
AutoIt         
#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
StringSize - Automatically size controls to fit text                                                               ExtMsgBox - A user customisable replacement for MsgBox
Toast - Small GUIs which pop out of the Systray                                                                Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command                                   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI                                      NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure      Notify - Small notifications on the edge of the display
Date_Time_Convert - Easily convert date/time formats, including the language               GUIListViewEx - Insert, delete, move, drag, sort and edit ListView items





Also tagged with one or more of these keywords: $WM_COMMAND, combobox

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users