Lupo73 Posted June 30, 2010 Share Posted June 30, 2010 Is it possible to connect two combobox and change items in a combo depending to the selected item of another? A sort of selection and subselection: the user select the archive format in the first combo (zip, 7z...) and than select the compression method in the second one (the list of methods is different for each format).I'm trying to use this example, recreating the second combo as event (and not updating a label as the example). But in my case it refresh the second combo each time mouse is hover the first one and doesn't allow to show the list of items in the combo itself. I think the problem is that I need to update the second combo when a new item is selected and not when the combo is selected.Thanks for your help! SFTPEx, AutoCompleteInput, _DateTimeStandard(), _ImageWriteResize(), _GUIGraduallyHide(): some AutoIt functions. Lupo PenSuite: all-in-one and completely free selection of portable programs and games. DropIt: a personal assistant to automatically manage your files. ArcThemALL!: application to multi-archive your files and folders. Link to comment Share on other sites More sharing options...
KaFu Posted June 30, 2010 Share Posted June 30, 2010 expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> GUICreate("My GUI") $cCombo1 = GUICtrlCreateCombo("7z", 10, 10) GUICtrlSetData(-1, "zip|rar", "7z") $cCombo2 = GUICtrlCreateCombo("7z - CM1", 10, 40) GUICtrlSetData(-1, "7z - CM2|7z - CM3", "7z - CM1") GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") GUISetState(@SW_SHOW) ; will display an empty dialog box ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd GUIDelete() Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam) $nNotifyCode = BitShift($wParam, 16) $nID = BitAND($wParam, 0x0000FFFF) $hCtrl = $lParam if $nID = $cCombo1 Then Switch GUICtrlRead($nID) Case "7z" GUICtrlSetData($cCombo2,"|7z - CM1|7z - CM2|7z - CM3","7z - CM1") Case "zip" GUICtrlSetData($cCombo2,"|zip - CM1|zip - CM2|zip - CM3","zip - CM1") Case "rar" GUICtrlSetData($cCombo2,"|rar - CM1|rar - CM2|rar - CM3","rar - CM1") EndSwitch endif Return $GUI_RUNDEFMSG EndFunc ;==>MY_WM_COMMAND OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Lupo73 Posted June 30, 2010 Author Share Posted June 30, 2010 Really thanks! It is the solution I was looking for.. SFTPEx, AutoCompleteInput, _DateTimeStandard(), _ImageWriteResize(), _GUIGraduallyHide(): some AutoIt functions. Lupo PenSuite: all-in-one and completely free selection of portable programs and games. DropIt: a personal assistant to automatically manage your files. ArcThemALL!: application to multi-archive your files and folders. Link to comment Share on other sites More sharing options...
Lupo73 Posted June 30, 2010 Author Share Posted June 30, 2010 I have implemented your code in my software. It works fine, but I have a secondary issue: the selection of the first combobox influences also a button visibility, but the button seems to be recreated when combobox is clicked (the button disappears and reappears with the click). What could be the problem? Is there a way to bypass this issue? thanks again.. Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam) Local $format, $status, $nNotifyCode, $nID, $hCtrl $nNotifyCode = BitShift($wParam, 16) $nID = BitAND($wParam, 0x0000FFFF) $hCtrl = $lParam If $nID = $ComboType Then $format = GUICtrlRead($nID) Switch $format Case "upx" GUICtrlSetData($ComboMode, $upxL, $upxM1) $status = $GUI_DISABLE Case "mpress" GUICtrlSetData($ComboMode, $upxL, $upxM1) $status = $GUI_DISABLE Case "zip", "7z" GUICtrlSetData($ComboMode, $zipL, $zipM1) $status = $GUI_ENABLE Case "archives" GUICtrlSetData($ComboMode, $unzL, $unzM1) $status = $GUI_ENABLE EndSwitch If $format = "archives" Then $format = "zip" IniWrite($sIni, "Options", "Format", $format) GUICtrlSetState($out, $status) EndIf Return $GUI_RUNDEFMSG EndFunc SFTPEx, AutoCompleteInput, _DateTimeStandard(), _ImageWriteResize(), _GUIGraduallyHide(): some AutoIt functions. Lupo PenSuite: all-in-one and completely free selection of portable programs and games. DropIt: a personal assistant to automatically manage your files. ArcThemALL!: application to multi-archive your files and folders. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 30, 2010 Moderators Share Posted June 30, 2010 Lupo73 , I use a different method to link the combos than Kafu (although his is sexier!) - I have added a few button visibility lines to show how I would do that as well: expandcollapse popup#include <GUIConstantsEx.au3> #include <GUIComboBox.au3> $hGUI = GUICreate("Test", 500, 500) $hCombo_1 = GUICtrlCreateCombo("", 10, 10, 230, 20) GUICtrlSetData(-1, "One|Two|Three") $hCombo_2 = GUICtrlCreateCombo("", 260, 10, 230, 20) GUICtrlSetState(-1, $GUI_DISABLE) $hButton_1 = GUICtrlCreateButton("Test 1", 10, 100, 80, 30) GUICtrlSetState(-1, $GUI_HIDE) $hButton_2 = GUICtrlCreateButton("Test 2", 100, 100, 80, 30) GUICtrlSetState(-1, $GUI_HIDE) $hButton_3 = GUICtrlCreateButton("Test 3", 190, 100, 80, 30) GUICtrlSetState(-1, $GUI_HIDE) $hButton_Reset = GUICtrlCreateButton("Reset", 280, 100, 80, 30) GUISetState() $sCurrCombo_1 = "" While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton_Reset For $i = $hButton_1 To $hButton_Reset GUICtrlSetState($i, $GUI_HIDE) Next $sCurrCombo_1 = "" _GUICtrlComboBox_SetEditText($hCombo_1, "") _GUICtrlComboBox_SetEditText($hCombo_2, "") GUICtrlSetState($hCombo_2, $GUI_DISABLE) EndSwitch If GUICtrlRead($hCombo_1) <> $sCurrCombo_1 And _GUICtrlComboBox_GetDroppedState($hCombo_1) = False Then For $i = $hButton_1 To $hButton_3 GUICtrlSetState($i, $GUI_HIDE) Next GUICtrlSetState($hButton_Reset, $GUI_SHOW) $sCurrCombo_1 = GUICtrlRead($hCombo_1) Switch $sCurrCombo_1 Case "One" GUICtrlSetData($hCombo_2, "|A|B|C") GUICtrlSetState($hButton_1, $GUI_SHOW) Case "Two" GUICtrlSetData($hCombo_2, "|D|E|F") GUICtrlSetState($hButton_2, $GUI_SHOW) Case "Three" GUICtrlSetData($hCombo_2, "|G|H|I") GUICtrlSetState($hButton_3, $GUI_SHOW) EndSwitch GUICtrlSetState($hCombo_2, $GUI_ENABLE) EndIf WEnd Does it help at all? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
KaFu Posted June 30, 2010 Share Posted June 30, 2010 I have implemented your code in my software. It works fine, but I have a secondary issue: the selection of the first combobox influences also a button visibility, but the button seems to be recreated when combobox is clicked (the button disappears and reappears with the click). Shouldn't GUICtrlSetState($out, $status) be something more like GUICtrlSetState($ComboMode, $status) ? I don't see $out decleared in your snippet... OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Lupo73 Posted June 30, 2010 Author Share Posted June 30, 2010 It's good also your second solution, Melba23.. Is there any relevant difference to use it instead of the previous one? (I have already implemented the first solution in my software) I have also resolved the second issue, moving externally the enabling/disabling button operation. Thanks! SFTPEx, AutoCompleteInput, _DateTimeStandard(), _ImageWriteResize(), _GUIGraduallyHide(): some AutoIt functions. Lupo PenSuite: all-in-one and completely free selection of portable programs and games. DropIt: a personal assistant to automatically manage your files. ArcThemALL!: application to multi-archive your files and folders. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 30, 2010 Moderators Share Posted June 30, 2010 Lupo73,Is there any relevant differenceIf the end result is the same, a logical positivist like me would say "No". But as I said above, Kafu's code is "sexier" because it uses the Windows message stream while I am "polling in the While...WEnd loop" which some (no names of course!) have been know to classify as a bit "sad". However, as I mentioned above, if it works........ You choose which you prefer. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Lupo73 Posted July 1, 2010 Author Share Posted July 1, 2010 But as I said above, Kafu's code is "sexier" because it uses the Windows message stream while I am "polling in the While...WEnd loop" which some (no names of course!) have been know to classify as a bit "sad". However, as I mentioned above, if it works........ Thank you very much for the code and the really good answer SFTPEx, AutoCompleteInput, _DateTimeStandard(), _ImageWriteResize(), _GUIGraduallyHide(): some AutoIt functions. Lupo PenSuite: all-in-one and completely free selection of portable programs and games. DropIt: a personal assistant to automatically manage your files. ArcThemALL!: application to multi-archive your files and folders. 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