JusGellin Posted July 17, 2009 Share Posted July 17, 2009 How could I operate two comboboxes such that when I drop down the first one, the second will automatically drop at the same time? The same would happen when I go down the items on the first combo, the second would automatically go to the same item. I tried triggering off the first combo, but the second combo only drops down after I'm out of the first combo. Thanks #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1_1 = GUICreate("Form1", 346, 116, 192, 124) $combo = GUICtrlCreateCombo("", 10, 60, 145, 25) GUICtrlSetData(-1, "item2|item3|item4") $combo2 = GUICtrlCreateCombo("", 180, 60, 145, 25) GUICtrlSetData(-1, "2|3|4") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $combo ControlCommand($Form1_1, "", $combo2, "ShowDropDown", "") EndSwitch WEnd Link to comment Share on other sites More sharing options...
BugFix Posted July 17, 2009 Share Posted July 17, 2009 (edited) Try this solution expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ListBoxConstants.au3> #Include <GuiComboBox.au3> Global $hCombo1, $hCombo2, $combo1, $combo2 $Form1_1 = GUICreate("Form1", 346, 116, 192, 124) $combo1 = GUICtrlCreateCombo("", 10, 60, 145, 25) GUICtrlSetData(-1, "item2|item3|item4") $hCombo1 = GUICtrlGetHandle($combo1) $combo2 = GUICtrlCreateCombo("", 180, 60, 145, 25) GUICtrlSetData(-1, "2|3|4") $hCombo2 = GUICtrlGetHandle($combo2) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom = $ilParam, $iCode = BitShift($iwParam, 16), $hCB, $index Switch $iCode Case $LBN_SELCHANGE ; Sent when the selection in a list box has changed Switch $hWndFrom Case $hCombo1 $hCB = $hCombo2 Case $hCombo2 $hCB = $hCombo1 EndSwitch $index = _GUICtrlComboBox_GetCurSel($hWndFrom) _GUICtrlComboBox_SetCurSel($hCB, $index) EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Edited July 17, 2009 by BugFix Best Regards BugFix Link to comment Share on other sites More sharing options...
JusGellin Posted July 17, 2009 Author Share Posted July 17, 2009 Try this solutionNo, not quite. I liked how you used GUIRegisterMsg, though.Thanks, but what I wanted it to do was when I pulled down the first combo, it would act like I was pulling down the second combo at the same time. My goal was to make a two column combo this way. I didn't want to put both column fields on the same line. Link to comment Share on other sites More sharing options...
martin Posted July 17, 2009 Share Posted July 17, 2009 Maybe you could create lisboxes which are hidden and positioned just below the combos. When one combo is shown, show the list box for the other combo which should look like the other combo has dropped down. Dropping 2 combos at once is unlikely to work IMO. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
BugFix Posted July 17, 2009 Share Posted July 17, 2009 it would act like I was pulling down the second combo at the same time.Oh, but opening two Combo(List-)Boxes at the same time is impossible afaik. It gives a conflict by set focus. Which Control should get the focus I think this will to confuse windows. Best Regards BugFix Link to comment Share on other sites More sharing options...
JusGellin Posted July 18, 2009 Author Share Posted July 18, 2009 Thanks for thinking about this. I understand the focus problem. I will look into building something like Martin suggested - that would be interesting to try. Link to comment Share on other sites More sharing options...
BugFix Posted July 18, 2009 Share Posted July 18, 2009 Here an quick&dirty solution: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ListViewConstants.au3> #Include <GuiComboBox.au3> Global $combo1, $hCombo1, $listview1, $state = False $Form1_1 = GUICreate("Form1", 346, 116, 192, 124) $combo1 = GUICtrlCreateCombo("", 10, 20, 145, 25) GUICtrlSetData(-1, "item2|item3|item4") $hCombo1 = GUICtrlGetHandle($combo1) $listview1 = GUICtrlCreateListView("col", 156, 40, 145, 48, BitOR($LVS_NOCOLUMNHEADER, $LVS_SHOWSELALWAYS, $LVS_SINGLESEL)) GUICtrlCreateListViewItem('2', $listview1) GUICtrlCreateListViewItem('3', $listview1) GUICtrlCreateListViewItem('4', $listview1) GUICtrlSetState($listview1, $GUI_HIDE) GUISetState(@SW_SHOW) AdlibEnable('_checkBox') While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _checkBox() Local $dropped = _GUICtrlComboBox_GetDroppedState($hCombo1) If $dropped = $state Then Return Switch $dropped Case True GUICtrlSetState($listview1, $GUI_SHOW) $state = True Case False GUICtrlSetState($listview1, $GUI_HIDE) $state = False EndSwitch EndFunc Best Regards BugFix Link to comment Share on other sites More sharing options...
JusGellin Posted July 18, 2009 Author Share Posted July 18, 2009 Here an quick&dirty solution:That's pretty cleaver!! Thanks for showing me more ideas. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now