Hobbyist Posted December 22, 2016 Share Posted December 22, 2016 I hope I'm in the right area for this question. My attached code just creates 12 Listviews and I am looking to be able to, after loading all of them, select ONE and that will also cause the other 11 to be hidden. I did read an old post (2011) that Melba23 had responded to and I tried to get some traction of it but apparently still doing something wrong. I'm sure its in the For/Next, since it works on the first Listview but not the rest. I thought perhaps the WIN API (get focus) would work but am drawing a blank there as well. My approach maynot be the best since I am new at this, so suggestions are welcome. Thanks Hobbyist expandcollapse popup#include <Array.au3> #include <Array.au3> #include <ButtonConstants.au3> #include <ColorConstants.au3> #include <ComboConstants.au3> #include <Date.au3> #include <EditConstants.au3> #include <File.au3> #include <GUIComboBox.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <GuiListView.au3> #include <ListViewConstants.au3> #include <Misc.au3> #include <MsgBoxConstants.au3> #include <StaticConstants.au3> #include <String.au3> #include <WindowsConstants.au3> #include <StringConstants.au3> #include <FileConstants.au3> #include <GuiTab.au3> #include <GuiButton.au3> #include <GuiMenu.au3> #include <WinAPI.au3> #include <Constants.au3> #include <WinAPIFiles.au3> #include <GuiDateTimePicker.au3> #include <Sound.au3> #include <GuiScrollBars.au3> ;I know I don't need all the above, its just a template that I throw everything into so I can move along each time ;Looking to create seris of Listviews but ONLY ONE is viewable at a time ;thought the array would be the place to store the needed data to CHANGE STATE depending upon any button I would put on it. global $ListAll[13] [2] $ListAll[0][0] = "ControlID" $ListAll[0][1] = "Handle" local $matrix [8] [18] = [ [ 0,"$List1","$List2","$List3","$List4","$List5","$List6", "$List7" ,"$List8", "$List9" , _ "$List12" , "$List13","$List100", "$Button4", "$Button12" , "$Button13", "$Button14", "$Button15"] , _ ["Hide",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] , ["Show",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], _ ["Enable",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] , ["disABLE",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], ["Checked",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], _ ["Unchecked",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], ["ControlID",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] ] ;_ArrayDisplay($matrix, "LABELS") ;update for state in column 0; for later, not the issue with WINAPI $matrix [1] [0] = $GUI_HIDE $matrix [2] [0] = $GUI_SHOW $matrix [3] [0] = $GUI_ENABLE $matrix[4][0] =$GUI_DISABLE $matrix [5] [0] = $GUI_CHECKED $matrix [6] [0] = $GUI_UNCHECKED ;_ArrayDisplay($matrix, "Update It") ; updated $main = GUICreate("Dash Board", 680, 515, 150, 100) ;height was 480 $Button14 = GUICtrlCreateButton("Matrix", 10, 140, 120, 33) ;load the listviews GUICtrlSetState($Button14,$GUI_enABLE) GUICtrlSetState($Button14,$GUI_show) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) GUICtrlSetBkColor(-1, 0xE3E3E3) GUICtrlSetState($Button14, $GUI_FOCUS) GUISetState(@SW_SHOW) GUISetState() While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit case $Button14 _SeeAll() ;create all Listviews and show ;EndSwitch ;Switch _WinAPI_GetFocus() ;; Looking to do this - click on ANY displayed Listview and that causes balance of listviews to HIDE Case $ListAll[1] [0] to $ListAll[12] [0] ;, $ListAll[1] [1] to $ListAll[12] [1] for $i = 1 to 12 If $iMsg = ($ListAll[$i][0] ) Then GUICtrlsetState( $ListAll[$i] [0], $GUI_focus) Else GUICtrlsetState( $ListAll[$i] [0], $GUI_HIDE) EndIf Next EndSwitch WEnd Func _SeeAll(); create all listviews for viewing before any selection $j = 40 GUISetState(@SW_LOCK) For $i = 1 to 12 $ListAll[$i][0] = GUICtrlCreateListview("$ListAll"&$i, 154, $j,500, 200 ) $ListAll[$i] [1]= GUICtrlGetHandle ($ListAll[$i][0] ) _GUICtrlListView_SetExtendedListViewStyle ( $ListAll,BitOR( $LVS_EX_HEADERDRAGDROP, $LVS_EX_GRIDLINES)) _GUICtrlListView_AddColumn( $ListAll[$i][0] , "A", 70) _GUICtrlListView_AddColumn( $ListAll[$i][0] , "B", 70) _GUICtrlListView_AddColumn( $ListAll[$i][0] , "C", 70) _GUICtrlListView_AddColumn( $ListAll[$i][0] , "D", 70) _GUICtrlListView_AddColumn( $ListAll[$i][0] , "E", 70) _GUICtrlListView_AddColumn( $ListAll[$i][0] , "F", 70) GUICtrlSetFont(-1, 8.5, 700, 0, "MS Ariel") GUICtrlSetBkColor( $ListAll[$i][0] , $COLOR_aqua) GUICtrlSetFont(-1, 8.5, 700, 0, "MS Ariel") GUICtrlSetState( $ListAll[$i][0] ,$matrix[2][0]); GUICtrlSetState( $ListAll[$i][0] ,$matrix[3][0]) $matrix [2] [$i] = 1 $matrix [3][$i] = 1 $j = $j + 30 next GUISetState(@SW_UNLOCK) _ArrayDisplay($ListAll, " listview array") ; controlID column 0, handle column 1 EndFunc Link to comment Share on other sites More sharing options...
careca Posted December 23, 2016 Share Posted December 23, 2016 Wow, where do i begin? Messy is the only word i find. Does it have to be this many listviews, and this many rows? Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
Hobbyist Posted December 23, 2016 Author Share Posted December 23, 2016 Thanks. Taking response under advisement. Link to comment Share on other sites More sharing options...
careca Posted December 23, 2016 Share Posted December 23, 2016 Im sorry mate, im working on it, and progressing slowly, didn't mean to put you down or anything. I may come up with something in a while. Through another method. Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
careca Posted December 23, 2016 Share Posted December 23, 2016 (edited) Came up with this: expandcollapse popup#include <Array.au3> #include <Array.au3> #include <ButtonConstants.au3> #include <ColorConstants.au3> #include <ComboConstants.au3> #include <Date.au3> #include <EditConstants.au3> #include <File.au3> #include <GUIComboBox.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <GuiListView.au3> #include <ListViewConstants.au3> #include <Misc.au3> #include <MsgBoxConstants.au3> #include <StaticConstants.au3> #include <String.au3> #include <WindowsConstants.au3> #include <StringConstants.au3> #include <FileConstants.au3> #include <GuiTab.au3> #include <GuiButton.au3> #include <GuiMenu.au3> #include <WinAPI.au3> #include <Constants.au3> #include <WinAPIFiles.au3> #include <GuiDateTimePicker.au3> #include <Sound.au3> #include <GuiScrollBars.au3> ;I know I don't need all the above, its just a template that I throw everything into so I can move along each time ;Looking to create seris of Listviews but ONLY ONE is viewable at a time ;thought the array would be the place to store the needed data to CHANGE STATE depending upon any button I would put on it. Global $ListAll[13][2] $ListAll[0][0] = "ControlID" $ListAll[0][1] = "Handle" Local $matrix[8][18] = [[0, "$List1", "$List2", "$List3", "$List4", "$List5", "$List6", "$List7", "$List8", "$List9", _ "$List12", "$List13", "$List100", "$Button4", "$Button12", "$Button13", "$Button14", "$Button15"], _ ["Hide", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ["Show", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], _ ["Enable", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ["disABLE", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ["Checked", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], _ ["Unchecked", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ["ControlID", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]] ;_ArrayDisplay($matrix, "LABELS") ;update for state in column 0; for later, not the issue with WINAPI $matrix[1][0] = $GUI_HIDE $matrix[2][0] = $GUI_SHOW $matrix[3][0] = $GUI_ENABLE $matrix[4][0] = $GUI_DISABLE $matrix[5][0] = $GUI_CHECKED $matrix[6][0] = $GUI_UNCHECKED ;_ArrayDisplay($matrix, "Update It") ; updated $main = GUICreate("Dash Board", 680, 515, 150, 100) ;height was 480 $Button14 = GUICtrlCreateButton("Matrix", 10, 140, 120, 33) ;load the listviews GUICtrlSetState($Button14, $GUI_enABLE) GUICtrlSetState($Button14, $GUI_show) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) GUICtrlSetBkColor(-1, 0xE3E3E3) GUICtrlSetState($Button14, $GUI_FOCUS) GUISetState(@SW_SHOW) GUISetState() While 1 $iMsg = GUIGetMsg() $Cur = GUIGetCursorInfo($main) ConsoleWrite(' - ' & $Cur[4] & ' - ' & @MSEC & @CRLF) Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case $Button14 _SeeAll() EndSwitch If _IsPressed('01') Then Sleep(100) If $Cur[4]<>3 Then For $u = 4 To 15 If $u = $Cur[4] Then GUICtrlSetState($u, $GUI_FOCUS) Else ;GUICtrlSetState($u, $GUI_HIDE) GUICtrlDelete($u) EndIf Next EndIf EndIf Sleep(50) WEnd Func _SeeAll(); create all listviews for viewing before any selection For $i = 4 To 15 GUICtrlDelete($i) Next $j = 40 GUISetState(@SW_LOCK) For $i = 1 To 12 $ListAll[$i][0] = GUICtrlCreateListView("$ListAll" & $i, 154, $j, 500, 200) $ListAll[$i][1] = GUICtrlGetHandle($ListAll[$i][0]) _GUICtrlListView_SetExtendedListViewStyle($ListAll, BitOR($LVS_EX_HEADERDRAGDROP, $LVS_EX_GRIDLINES)) _GUICtrlListView_AddColumn($ListAll[$i][0], "A", 70) _GUICtrlListView_AddColumn($ListAll[$i][0], "B", 70) _GUICtrlListView_AddColumn($ListAll[$i][0], "C", 70) _GUICtrlListView_AddColumn($ListAll[$i][0], "D", 70) _GUICtrlListView_AddColumn($ListAll[$i][0], "E", 70) _GUICtrlListView_AddColumn($ListAll[$i][0], "F", 70) GUICtrlSetFont(-1, 8.5, 700, 0, "MS Ariel") GUICtrlSetBkColor($ListAll[$i][0], $COLOR_aqua) GUICtrlSetFont(-1, 8.5, 700, 0, "MS Ariel") GUICtrlSetState($ListAll[$i][0], $matrix[2][0]); GUICtrlSetState($ListAll[$i][0], $matrix[3][0]) $matrix[2][$i] = 1 $matrix[3][$i] = 1 $j = $j + 30 Next GUISetState(@SW_UNLOCK) ;_ArrayDisplay($ListAll, " listview array") ; controlID column 0, handle column 1 EndFunc ;==>_SeeAll But there's a problem, as it uses gui ID's, it only works until you press Matrix again, then the id's are no longer from 4 to 15 in terms of the listviews, it will add up... If you manage to, say, delete the listviews instead of hiding, might work this way. Added the delete in the function. Edited December 23, 2016 by careca Hmmm might be fixed. Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
Subz Posted December 23, 2016 Share Posted December 23, 2016 What about: expandcollapse popup#include <Array.au3> #include <ColorConstants.au3> #include <GuiComboBox.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <ListViewConstants.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> Global $hGUI_COMBOBOX, $hGUI_LISTVIEW Global $aListView01[1][6], $aListView02[1][6], $aListView03[1][6], $aListView04[1][6], $aListView05[1][6], $aListView06[1][6], $aListView07[1][6], $aListView08[1][6], $aListView09[1][6], $aListView10[1][6], $aListView11[1][6], $aListView12[1][6] Global $aComboBox[13] = [12, 'ListView 01', 'ListView 02', 'ListView 03', 'ListView 04', 'ListView 05', 'ListView 06', 'ListView 07', 'ListView 08', 'ListView 09', 'ListView 10', 'ListView 11', 'ListView 12'] Global $aListView[13] = [12, $aListView01, $aListView02, $aListView03, $aListView04, $aListView05, $aListView06, $aListView07, $aListView08, $aListView09, $aListView10, $aListView11, $aListView12] AssignLV() Example() Func Example() Local $hGUI $hGUI = GUICreate("Dash Board", 510, 235, 150, 100) $hGUI_COMBOBOX = GUICtrlCreateCombo("", 5, 5, 250, 20) GUICtrlSetData($hGUI_COMBOBOX, _ArrayToString($aComboBox, '|', 1)) $hGUI_LISTVIEW = GUICtrlCreateListView('Column A|Column B|Column C|Column D|Column E|Column F', 5, 30, 500, 200, '', BitOR($LVS_EX_HEADERDRAGDROP, $LVS_EX_GRIDLINES)) GUICtrlSetFont($hGUI_LISTVIEW, 8.5, 700, 0, "MS Ariel") GUICtrlSetBkColor($hGUI_LISTVIEW, $COLOR_aqua) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode $hWndFrom = $lParam $iIDFrom = BitAND($wParam, 0xFFFF) $iCode = BitShift($wParam, 16) Switch $iIDFrom Case $hGUI_COMBOBOX Switch $iCode Case $CBN_SELCHANGE _GUICtrlListView_DeleteAllItems($hGUI_LISTVIEW) Local $iGUI_COMBOBOX = _GUICtrlComboBox_GetCurSel($hGUI_COMBOBOX) + 1 _GUICtrlListView_AddArray($hGUI_LISTVIEW, $aListView[$iGUI_COMBOBOX]) For $i = 0 To _GUICtrlListView_GetColumnCount($hGUI_LISTVIEW) - 1 If $i = _GUICtrlListView_GetColumnCount($hGUI_LISTVIEW) - 1 Then ConsoleWrite($i & @CRLF) _GUICtrlListView_SetColumnWidth($hGUI_LISTVIEW, $i, $LVSCW_AUTOSIZE_USEHEADER) ExitLoop EndIf _GUICtrlListView_SetColumnWidth($hGUI_LISTVIEW, $i, 70) Next EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func AssignLV() Local $aTempView For $x = 1 To 12 $aTempView = $aListView[$x] ReDim $aTempView[Random(4, 30)][6] For $y = 0 To UBound($aTempView) - 1 $aTempView[$y][0] = $x & '-' & $y & 'A' $aTempView[$y][1] = $x & '-' & $y & 'B' $aTempView[$y][2] = $x & '-' & $y & 'C' $aTempView[$y][3] = $x & '-' & $y & 'D' $aTempView[$y][4] = $x & '-' & $y & 'E' $aTempView[$y][5] = $x & '-' & $y & 'F' Next $aListView[$x] = $aTempView Next EndFunc Link to comment Share on other sites More sharing options...
Hobbyist Posted December 23, 2016 Author Share Posted December 23, 2016 @careca @Subz Thank you both. I will be trying both. @careca, your script does what i was attempting to do, as I thought of it. The matrix button was there just so when I loaded listviews I could see what was going on. My intention would be to create/display listviews at loading of program and the matrix would be my reset button to again display all of them. Had not decided on "hide" or "delete at this point as my first hurdle was the getting one to display/and not seeing the other 11. I understand the ID is lost if I delete and recreate, thus i was seeking to use an array item so as to always be able to capture the ID no matter what. Not sure of the advantagees of delete or hide from a resource view(albeit this is small potatoes). Also If I use an array, I might be able to enlarge the 2D so as to hold additonal states of other controls associated with each listview. @Subz, your script is an alternate way that I didn't have a thought of doing it that way. I like it too. Since it is a little more in depth than the other, I need to really look at the script(I am so new at this) to see the "how's". And add comment lines so I can keep it straight. And I would be looking to see if I would be able to asssociate other controls with any given listview selection. The other controls would NOT necessarily be the same for each listview. The one thing I did notice in your approach was if I try to type the listview name in the combo, it does not take it, leaving only the mouse or arrow down. Both of you have been very helpful and again any coding advice is appreciated, especially ones that would help me from making design mistakes. I will post again after I spend some time incorporating both methods in separate scripts to see how it goes. Thanks again. And I apologize for the messy first script post. Hobbyist Link to comment Share on other sites More sharing options...
Subz Posted December 23, 2016 Share Posted December 23, 2016 Another example with Autocomplete {tab} and two ListViews expandcollapse popup#include <Array.au3> #include <ColorConstants.au3> #include <GuiComboBox.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <ListViewConstants.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> Global $hGUI_COMBOBOX01, $hGUI_COMBOBOX02 Global $hGUI_LISTVIEW01, $hGUI_LISTVIEW02 Global $aListView01[1][6], $aListView02[1][6], $aListView03[1][6], $aListView04[1][6], $aListView05[1][6], $aListView06[1][6], $aListView07[1][6], $aListView08[1][6], $aListView09[1][6], $aListView10[1][6], $aListView11[1][6], $aListView12[1][6] Global $aComboBox[13] = [12, 'ListView 01', 'ListView 02', 'ListView 03', 'ListView 04', 'ListView 05', 'ListView 06', 'ListView 07', 'ListView 08', 'ListView 09', 'ListView 10', 'ListView 11', 'ListView 12'] Global $aListView[13] = [12, $aListView01, $aListView02, $aListView03, $aListView04, $aListView05, $aListView06, $aListView07, $aListView08, $aListView09, $aListView10, $aListView11, $aListView12] AssignLV() Example() Func Example() Local $hGUI $hGUI = GUICreate("Dash Board", 510, 480, 150, 100) $hGUI_COMBOBOX01 = GUICtrlCreateCombo("", 5, 5, 250, 20) GUICtrlSetData($hGUI_COMBOBOX01, _ArrayToString($aComboBox, '|', 1)) $hGUI_LISTVIEW01 = GUICtrlCreateListView('Column A|Column B|Column C|Column D|Column E|Column F', 5, 30, 500, 200, '', BitOR($LVS_EX_HEADERDRAGDROP, $LVS_EX_GRIDLINES)) GUICtrlSetFont($hGUI_LISTVIEW01, 8.5, 700, 0, "MS Ariel") GUICtrlSetBkColor($hGUI_LISTVIEW01, $COLOR_aqua) $hGUI_COMBOBOX02 = GUICtrlCreateCombo("", 5, 250, 250, 20) GUICtrlSetData($hGUI_COMBOBOX02, _ArrayToString($aComboBox, '|', 1)) $hGUI_LISTVIEW02 = GUICtrlCreateListView('Column A|Column B|Column C|Column D|Column E|Column F', 5, 275, 500, 200, '', BitOR($LVS_EX_HEADERDRAGDROP, $LVS_EX_GRIDLINES)) GUICtrlSetFont($hGUI_LISTVIEW02, 8.5, 700, 0, "MS Ariel") GUICtrlSetBkColor($hGUI_LISTVIEW02, $COLOR_TEAL) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode, $iGUI_COMBOBOX $hWndFrom = $lParam $iIDFrom = BitAND($wParam, 0xFFFF) $iCode = BitShift($wParam, 16) Switch $iIDFrom Case $hGUI_COMBOBOX01 Switch $iCode Case $CBN_EDITCHANGE _Edit_Changed($hGUI_COMBOBOX01) Case $CBN_SELENDCANCEL, $CBN_SELCHANGE If _GUICtrlComboBox_SelectString($hGUI_COMBOBOX01, GUICtrlRead($hGUI_COMBOBOX01)) >= 0 Then _GUICtrlListView_DeleteAllItems($hGUI_LISTVIEW01) $iGUI_COMBOBOX = _GUICtrlComboBox_GetCurSel($hGUI_COMBOBOX01) + 1 _GUICtrlListView_AddArray($hGUI_LISTVIEW01, $aListView[$iGUI_COMBOBOX]) For $i = 0 To _GUICtrlListView_GetColumnCount($hGUI_LISTVIEW01) - 1 If $i = _GUICtrlListView_GetColumnCount($hGUI_LISTVIEW01) - 1 Then _GUICtrlListView_SetColumnWidth($hGUI_LISTVIEW01, $i, $LVSCW_AUTOSIZE_USEHEADER) ExitLoop EndIf _GUICtrlListView_SetColumnWidth($hGUI_LISTVIEW01, $i, 70) Next EndIf EndSwitch Case $hGUI_COMBOBOX02 Switch $iCode Case $CBN_EDITCHANGE _Edit_Changed($hGUI_COMBOBOX02) Case $CBN_SELENDCANCEL, $CBN_SELCHANGE If _GUICtrlComboBox_SelectString($hGUI_COMBOBOX02, GUICtrlRead($hGUI_COMBOBOX02)) >= 0 Then _GUICtrlListView_DeleteAllItems($hGUI_LISTVIEW02) $iGUI_COMBOBOX = _GUICtrlComboBox_GetCurSel($hGUI_COMBOBOX02) + 1 _GUICtrlListView_AddArray($hGUI_LISTVIEW02, $aListView[$iGUI_COMBOBOX]) For $i = 0 To _GUICtrlListView_GetColumnCount($hGUI_LISTVIEW02) - 1 If $i = _GUICtrlListView_GetColumnCount($hGUI_LISTVIEW02) - 1 Then _GUICtrlListView_SetColumnWidth($hGUI_LISTVIEW02, $i, $LVSCW_AUTOSIZE_USEHEADER) ExitLoop EndIf _GUICtrlListView_SetColumnWidth($hGUI_LISTVIEW02, $i, 70) Next EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func _Edit_Changed($hGUI_COMBOBOX) _GUICtrlComboBox_AutoComplete($hGUI_COMBOBOX) EndFunc Func AssignLV() Local $aTempView For $x = 1 To 12 $aTempView = $aListView[$x] ReDim $aTempView[Random(4, 30)][6] For $y = 0 To UBound($aTempView) - 1 $aTempView[$y][0] = $x & '-' & $y & 'A' $aTempView[$y][1] = $x & '-' & $y & 'B' $aTempView[$y][2] = $x & '-' & $y & 'C' $aTempView[$y][3] = $x & '-' & $y & 'D' $aTempView[$y][4] = $x & '-' & $y & 'E' $aTempView[$y][5] = $x & '-' & $y & 'F' Next $aListView[$x] = $aTempView Next EndFunc Link to comment Share on other sites More sharing options...
Hobbyist Posted December 24, 2016 Author Share Posted December 24, 2016 @Subz I took your last script and attempted something but apparently failed. The autofill is nice and efficient, so I attempted to also make the possibility of hitting the Enter key, rather than mouse click or arrow down. The two most valuable would be the mouse and Enter key. So I tried the accelerator key approach. Your opinion?? Lines 18, 33 and 74 are where I inserted my code attempt. What did I do wrong? Now if I Show the Button and click it, the balance of your script works. If I use the Enter key - nothing. Look for the ;//////////// expandcollapse popup#include <Array.au3> #include <ColorConstants.au3> #include <GuiComboBox.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <ListViewConstants.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> Global $hGUI_COMBOBOX01, $hGUI_COMBOBOX02 Global $hGUI_LISTVIEW01, $hGUI_LISTVIEW02 Global $aListView01[1][6], $aListView02[1][6], $aListView03[1][6], $aListView04[1][6], $aListView05[1][6], $aListView06[1][6], $aListView07[1][6], $aListView08[1][6], $aListView09[1][6], $aListView10[1][6], $aListView11[1][6], $aListView12[1][6] Global $aComboBox[13] = [12, 'ListView 01', 'ListView 02', 'ListView 03', 'ListView 04', 'ListView 05', 'ListView 06', 'ListView 07', 'ListView 08', 'ListView 09', 'ListView 10', 'ListView 11', 'ListView 12'] Global $aListView[13] = [12, $aListView01, $aListView02, $aListView03, $aListView04, $aListView05, $aListView06, $aListView07, $aListView08, $aListView09, $aListView10, $aListView11, $aListView12] ;creat ability to hit enter key AFTER typing choice and getting autofill ?????? ;/////////////////////////////////////////////////////////// local $Button1 = GUICtrlCreateButton("Submit",275, 5, 25, 20) GUICtrlSetState($Button1, $GUI_hide) ; hide the button. hit enter should be same as clicking button????? Opt("GUIOnEventMode", 1) GUICtrlSetOnEvent($Button1, "_submitbtn") Dim $AccelKeys[1][2]=[["{Enter}", $Button1]] GUISetAccelerators($AccelKeys) ;//////////////////////////////////////////////////////////// AssignLV() Example() ;///////////////////////////////////////////////// Func _submitbtn() ; call function after _Edit_Changed($hGUI_COMBOBOX01) to populate the listview like the current click selection GUICtrlRead($hGUI_COMBOBOX01 ) EndFunc ;/////////////////////////////////////////////// Func Example() Local $hGUI $hGUI = GUICreate("Dash Board", 510, 480, 150, 100) $hGUI_COMBOBOX01 = GUICtrlCreateCombo("", 5, 5, 250, 20) GUICtrlSetData($hGUI_COMBOBOX01, _ArrayToString($aComboBox, '|', 1)) $hGUI_LISTVIEW01 = GUICtrlCreateListView('Column A|Column B|Column C|Column D|Column E|Column F', 5, 30, 500, 200, '', BitOR($LVS_EX_HEADERDRAGDROP, $LVS_EX_GRIDLINES)) GUICtrlSetFont($hGUI_LISTVIEW01, 8.5, 700, 0, "MS Ariel") GUICtrlSetBkColor($hGUI_LISTVIEW01, $COLOR_aqua) $hGUI_COMBOBOX02 = GUICtrlCreateCombo("", 5, 250, 250, 20) GUICtrlSetData($hGUI_COMBOBOX02, _ArrayToString($aComboBox, '|', 1)) $hGUI_LISTVIEW02 = GUICtrlCreateListView('Column A|Column B|Column C|Column D|Column E|Column F', 5, 275, 500, 200, '', BitOR($LVS_EX_HEADERDRAGDROP, $LVS_EX_GRIDLINES)) GUICtrlSetFont($hGUI_LISTVIEW02, 8.5, 700, 0, "MS Ariel") GUICtrlSetBkColor($hGUI_LISTVIEW02, $COLOR_TEAL) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode, $iGUI_COMBOBOX $hWndFrom = $lParam $iIDFrom = BitAND($wParam, 0xFFFF) $iCode = BitShift($wParam, 16) Switch $iIDFrom Case $hGUI_COMBOBOX01 Switch $iCode Case $CBN_EDITCHANGE _Edit_Changed($hGUI_COMBOBOX01) _submitbtn() ;<<<<<<<<<<<<<<<<<<<<<<<<<< ;//////////////////////////////////////////// Case $CBN_SELENDCANCEL, $CBN_SELCHANGE If _GUICtrlComboBox_SelectString($hGUI_COMBOBOX01, GUICtrlRead($hGUI_COMBOBOX01)) >= 0 Then _GUICtrlListView_DeleteAllItems($hGUI_LISTVIEW01) $iGUI_COMBOBOX = _GUICtrlComboBox_GetCurSel($hGUI_COMBOBOX01) + 1 _GUICtrlListView_AddArray($hGUI_LISTVIEW01, $aListView[$iGUI_COMBOBOX]) For $i = 0 To _GUICtrlListView_GetColumnCount($hGUI_LISTVIEW01) - 1 If $i = _GUICtrlListView_GetColumnCount($hGUI_LISTVIEW01) - 1 Then _GUICtrlListView_SetColumnWidth($hGUI_LISTVIEW01, $i, $LVSCW_AUTOSIZE_USEHEADER) ExitLoop EndIf _GUICtrlListView_SetColumnWidth($hGUI_LISTVIEW01, $i, 70) Next EndIf EndSwitch Case $hGUI_COMBOBOX02 Switch $iCode Case $CBN_EDITCHANGE _Edit_Changed($hGUI_COMBOBOX02) Case $CBN_SELENDCANCEL, $CBN_SELCHANGE If _GUICtrlComboBox_SelectString($hGUI_COMBOBOX02, GUICtrlRead($hGUI_COMBOBOX02)) >= 0 Then _GUICtrlListView_DeleteAllItems($hGUI_LISTVIEW02) $iGUI_COMBOBOX = _GUICtrlComboBox_GetCurSel($hGUI_COMBOBOX02) + 1 _GUICtrlListView_AddArray($hGUI_LISTVIEW02, $aListView[$iGUI_COMBOBOX]) For $i = 0 To _GUICtrlListView_GetColumnCount($hGUI_LISTVIEW02) - 1 If $i = _GUICtrlListView_GetColumnCount($hGUI_LISTVIEW02) - 1 Then _GUICtrlListView_SetColumnWidth($hGUI_LISTVIEW02, $i, $LVSCW_AUTOSIZE_USEHEADER) ExitLoop EndIf _GUICtrlListView_SetColumnWidth($hGUI_LISTVIEW02, $i, 70) Next EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func _Edit_Changed($hGUI_COMBOBOX) _GUICtrlComboBox_AutoComplete($hGUI_COMBOBOX) EndFunc Func AssignLV() Local $aTempView For $x = 1 To 12 $aTempView = $aListView[$x] ReDim $aTempView[Random(4, 30)][6] For $y = 0 To UBound($aTempView) - 1 $aTempView[$y][0] = $x & '-' & $y & 'A' $aTempView[$y][1] = $x & '-' & $y & 'B' $aTempView[$y][2] = $x & '-' & $y & 'C' $aTempView[$y][3] = $x & '-' & $y & 'D' $aTempView[$y][4] = $x & '-' & $y & 'E' $aTempView[$y][5] = $x & '-' & $y & 'F' Next $aListView[$x] = $aTempView Next EndFunc Thanks Hobbyist Link to comment Share on other sites More sharing options...
Hobbyist Posted December 24, 2016 Author Share Posted December 24, 2016 @careca I ran your script and think I recall the array showing the ID being the same each time I hit the button. My choices would be to delete or hide. Do you have an opinion on that? Also I haven't actually began the design as I am trying to line eveything up before hand. In the case of either solution, I still am interested in using an array/matrix to control the state of controls that might be associated with each listview. They will not be the same across the board so there would be several hide, show, disable, able lines in each case. The original posted script (messy) had the matrix idea in it but not functional. Hobbyist Link to comment Share on other sites More sharing options...
Subz Posted December 24, 2016 Share Posted December 24, 2016 Sorry, Xmas eve here in NZ, so haven't had a lot of time to look over it all but personally I would probably just check if {ENTER} is pressed within the ComboBox and then send a {TAB} for example: expandcollapse popup#include <Array.au3> #include <ColorConstants.au3> #include <GuiComboBox.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <ListViewConstants.au3> #include <Misc.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> Global $bGUI_COMBOBOX01 = False, $bGUI_COMBOBOX02 = False Global $hGUI_COMBOBOX01, $hGUI_COMBOBOX02 Global $hGUI_LISTVIEW01, $hGUI_LISTVIEW02 Global $aListView01[1][6], $aListView02[1][6], $aListView03[1][6], $aListView04[1][6], $aListView05[1][6], $aListView06[1][6], $aListView07[1][6], $aListView08[1][6], $aListView09[1][6], $aListView10[1][6], $aListView11[1][6], $aListView12[1][6] Global $aComboBox[13] = [12, 'ListView 01', 'ListView 02', 'ListView 03', 'ListView 04', 'ListView 05', 'ListView 06', 'ListView 07', 'ListView 08', 'ListView 09', 'ListView 10', 'ListView 11', 'ListView 12'] Global $aListView[13] = [12, $aListView01, $aListView02, $aListView03, $aListView04, $aListView05, $aListView06, $aListView07, $aListView08, $aListView09, $aListView10, $aListView11, $aListView12] AssignLV() Example() Func Example() Local $hGUI $hGUI = GUICreate("Dash Board", 510, 480, 150, 100) $hGUI_COMBOBOX01 = GUICtrlCreateCombo("", 5, 5, 250, 20, $CBS_DROPDOWN) GUICtrlSetData($hGUI_COMBOBOX01, _ArrayToString($aComboBox, '|', 1)) $hGUI_LISTVIEW01 = GUICtrlCreateListView('Column A|Column B|Column C|Column D|Column E|Column F', 5, 30, 500, 200, '', BitOR($LVS_EX_HEADERDRAGDROP, $LVS_EX_GRIDLINES)) GUICtrlSetFont($hGUI_LISTVIEW01, 8.5, 700, 0, "MS Ariel") GUICtrlSetBkColor($hGUI_LISTVIEW01, $COLOR_aqua) $hGUI_COMBOBOX02 = GUICtrlCreateCombo("", 5, 250, 250, 20) GUICtrlSetData($hGUI_COMBOBOX02, _ArrayToString($aComboBox, '|', 1)) $hGUI_LISTVIEW02 = GUICtrlCreateListView('Column A|Column B|Column C|Column D|Column E|Column F', 5, 275, 500, 200, '', BitOR($LVS_EX_HEADERDRAGDROP, $LVS_EX_GRIDLINES)) GUICtrlSetFont($hGUI_LISTVIEW02, 8.5, 700, 0, "MS Ariel") GUICtrlSetBkColor($hGUI_LISTVIEW02, $COLOR_TEAL) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $MSG = GUIGetMsg() Switch $MSG Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd GUIDelete() EndFunc Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode, $iGUI_COMBOBOX $hWndFrom = $lParam $iIDFrom = BitAND($wParam, 0xFFFF) $iCode = BitShift($wParam, 16) Switch $iIDFrom Case $hGUI_COMBOBOX01 Switch $iCode Case $CBN_EDITCHANGE _Edit_Changed($hGUI_COMBOBOX01) $bGUI_COMBOBOX01 = True Case $CBN_SELENDCANCEL, $CBN_SELCHANGE If _GUICtrlComboBox_SelectString($hGUI_COMBOBOX01, GUICtrlRead($hGUI_COMBOBOX01)) >= 0 Then _GUICtrlListView_DeleteAllItems($hGUI_LISTVIEW01) $iGUI_COMBOBOX = _GUICtrlComboBox_GetCurSel($hGUI_COMBOBOX01) + 1 _GUICtrlListView_AddArray($hGUI_LISTVIEW01, $aListView[$iGUI_COMBOBOX]) For $i = 0 To _GUICtrlListView_GetColumnCount($hGUI_LISTVIEW01) - 1 If $i = _GUICtrlListView_GetColumnCount($hGUI_LISTVIEW01) - 1 Then _GUICtrlListView_SetColumnWidth($hGUI_LISTVIEW01, $i, $LVSCW_AUTOSIZE_USEHEADER) ExitLoop EndIf _GUICtrlListView_SetColumnWidth($hGUI_LISTVIEW01, $i, 70) Next Else _GUICtrlListView_DeleteAllItems($hGUI_LISTVIEW01) _GUICtrlComboBox_SetCurSel($hGUI_COMBOBOX01, -1) EndIf Case $CBN_KILLFOCUS $bGUI_COMBOBOX01 = False EndSwitch Case $hGUI_COMBOBOX02 Switch $iCode Case $CBN_EDITCHANGE _Edit_Changed($hGUI_COMBOBOX02) $bGUI_COMBOBOX02 = True Case $CBN_SELENDCANCEL, $CBN_SELCHANGE If _GUICtrlComboBox_SelectString($hGUI_COMBOBOX02, GUICtrlRead($hGUI_COMBOBOX02)) >= 0 Then _GUICtrlListView_DeleteAllItems($hGUI_LISTVIEW02) $iGUI_COMBOBOX = _GUICtrlComboBox_GetCurSel($hGUI_COMBOBOX02) + 1 _GUICtrlListView_AddArray($hGUI_LISTVIEW02, $aListView[$iGUI_COMBOBOX]) For $i = 0 To _GUICtrlListView_GetColumnCount($hGUI_LISTVIEW02) - 1 If $i = _GUICtrlListView_GetColumnCount($hGUI_LISTVIEW02) - 1 Then _GUICtrlListView_SetColumnWidth($hGUI_LISTVIEW02, $i, $LVSCW_AUTOSIZE_USEHEADER) ExitLoop EndIf _GUICtrlListView_SetColumnWidth($hGUI_LISTVIEW02, $i, 70) Next Else _GUICtrlListView_DeleteAllItems($hGUI_LISTVIEW02) _GUICtrlComboBox_SetCurSel($hGUI_COMBOBOX02) EndIf Case $CBN_KILLFOCUS $bGUI_COMBOBOX02 = False EndSwitch EndSwitch If _IsPressed('0D') Then If $bGUI_COMBOBOX01 = True Then Send('{TAB}') ElseIf $bGUI_COMBOBOX02 = True Then Send('{TAB}') EndIf EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func _Edit_Changed($hGUI_COMBOBOX) _GUICtrlComboBox_AutoComplete($hGUI_COMBOBOX) EndFunc Func AssignLV() Local $aTempView For $x = 1 To 12 $aTempView = $aListView[$x] ReDim $aTempView[Random(4, 30)][6] For $y = 0 To UBound($aTempView) - 1 $aTempView[$y][0] = $x & '-' & $y & 'A' $aTempView[$y][1] = $x & '-' & $y & 'B' $aTempView[$y][2] = $x & '-' & $y & 'C' $aTempView[$y][3] = $x & '-' & $y & 'D' $aTempView[$y][4] = $x & '-' & $y & 'E' $aTempView[$y][5] = $x & '-' & $y & 'F' Next $aListView[$x] = $aTempView Next EndFunc Hobbyist 1 Link to comment Share on other sites More sharing options...
kylomas Posted December 24, 2016 Share Posted December 24, 2016 (edited) Hobbyist, Fixed the accelerator problem and added exit statement. Accelerators are associated with a control, therefore they must be made after the gui exists. You don't need hidden buttons. You certainly should not "SEND" keys to you own gui. Also, do not mix message loop and on event modes... expandcollapse popup#include <Array.au3> #include <ColorConstants.au3> #include <GuiComboBox.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <ListViewConstants.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> Global $hGUI_COMBOBOX01, $hGUI_COMBOBOX02 Global $hGUI_LISTVIEW01, $hGUI_LISTVIEW02 Global $aListView01[1][6], $aListView02[1][6], $aListView03[1][6], $aListView04[1][6], $aListView05[1][6], $aListView06[1][6], $aListView07[1][6], $aListView08[1][6], $aListView09[1][6], $aListView10[1][6], $aListView11[1][6], $aListView12[1][6] Global $aComboBox[13] = [12, 'ListView 01', 'ListView 02', 'ListView 03', 'ListView 04', 'ListView 05', 'ListView 06', 'ListView 07', 'ListView 08', 'ListView 09', 'ListView 10', 'ListView 11', 'ListView 12'] Global $aListView[13] = [12, $aListView01, $aListView02, $aListView03, $aListView04, $aListView05, $aListView06, $aListView07, $aListView08, $aListView09, $aListView10, $aListView11, $aListView12] Opt("GUIOnEventMode", 1) AssignLV() Example() ;///////////////////////////////////////////////// Func _submitbtn() ; call function after _Edit_Changed($hGUI_COMBOBOX01) to populate the listview like the current click selection GUICtrlRead($hGUI_COMBOBOX01 ) ConsoleWrite(GUICtrlRead($hGUI_COMBOBOX01 ) & @CRLF) EndFunc ;/////////////////////////////////////////////// Func Example() Local $hGUI $hGUI = GUICreate("Dash Board", 510, 480, 150, 100) ; to allow the gui to close with the systm control ("x") GUISetOnEvent($GUI_EVENT_CLOSE, "On_Exit") $hGUI_COMBOBOX01 = GUICtrlCreateCombo("", 5, 5, 250, 20) GUICtrlSetData($hGUI_COMBOBOX01, _ArrayToString($aComboBox, '|', 1)) $hGUI_LISTVIEW01 = GUICtrlCreateListView('Column A|Column B|Column C|Column D|Column E|Column F', 5, 30, 500, 200, '', BitOR($LVS_EX_HEADERDRAGDROP, $LVS_EX_GRIDLINES)) GUICtrlSetFont($hGUI_LISTVIEW01, 8.5, 700, 0, "MS Ariel") GUICtrlSetBkColor($hGUI_LISTVIEW01, $COLOR_aqua) $hGUI_COMBOBOX02 = GUICtrlCreateCombo("", 5, 250, 250, 20) GUICtrlSetData($hGUI_COMBOBOX02, _ArrayToString($aComboBox, '|', 1)) $hGUI_LISTVIEW02 = GUICtrlCreateListView('Column A|Column B|Column C|Column D|Column E|Column F', 5, 275, 500, 200, '', BitOR($LVS_EX_HEADERDRAGDROP, $LVS_EX_GRIDLINES)) GUICtrlSetFont($hGUI_LISTVIEW02, 8.5, 700, 0, "MS Ariel") GUICtrlSetBkColor($hGUI_LISTVIEW02, $COLOR_TEAL) ; accelerator key is associated with a control, therefore after the gui is created... local $dummy01 = GUICtrlCreateDummy() GUICtrlSetOnEvent($dummy01, "_submitbtn") Dim $AccelKeys[1][2]=[["{Enter}", $dummy01]] GUISetAccelerators($AccelKeys) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") while 1 sleep(10) wend ; do not mix message and event mode ;~ Do ;~ Until GUIGetMsg() = $GUI_EVENT_CLOSE ;~ GUIDelete() ; do not mix message and event mode EndFunc Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode, $iGUI_COMBOBOX $hWndFrom = $lParam $iIDFrom = BitAND($wParam, 0xFFFF) $iCode = BitShift($wParam, 16) Switch $iIDFrom Case $hGUI_COMBOBOX01 Switch $iCode Case $CBN_EDITCHANGE _Edit_Changed($hGUI_COMBOBOX01) _submitbtn() ;<<<<<<<<<<<<<<<<<<<<<<<<<< ;//////////////////////////////////////////// Case $CBN_SELENDCANCEL, $CBN_SELCHANGE If _GUICtrlComboBox_SelectString($hGUI_COMBOBOX01, GUICtrlRead($hGUI_COMBOBOX01)) >= 0 Then _GUICtrlListView_DeleteAllItems($hGUI_LISTVIEW01) $iGUI_COMBOBOX = _GUICtrlComboBox_GetCurSel($hGUI_COMBOBOX01) + 1 _GUICtrlListView_AddArray($hGUI_LISTVIEW01, $aListView[$iGUI_COMBOBOX]) For $i = 0 To _GUICtrlListView_GetColumnCount($hGUI_LISTVIEW01) - 1 If $i = _GUICtrlListView_GetColumnCount($hGUI_LISTVIEW01) - 1 Then _GUICtrlListView_SetColumnWidth($hGUI_LISTVIEW01, $i, $LVSCW_AUTOSIZE_USEHEADER) ExitLoop EndIf _GUICtrlListView_SetColumnWidth($hGUI_LISTVIEW01, $i, 70) Next EndIf EndSwitch Case $hGUI_COMBOBOX02 Switch $iCode Case $CBN_EDITCHANGE _Edit_Changed($hGUI_COMBOBOX02) Case $CBN_SELENDCANCEL, $CBN_SELCHANGE If _GUICtrlComboBox_SelectString($hGUI_COMBOBOX02, GUICtrlRead($hGUI_COMBOBOX02)) >= 0 Then _GUICtrlListView_DeleteAllItems($hGUI_LISTVIEW02) $iGUI_COMBOBOX = _GUICtrlComboBox_GetCurSel($hGUI_COMBOBOX02) + 1 _GUICtrlListView_AddArray($hGUI_LISTVIEW02, $aListView[$iGUI_COMBOBOX]) For $i = 0 To _GUICtrlListView_GetColumnCount($hGUI_LISTVIEW02) - 1 If $i = _GUICtrlListView_GetColumnCount($hGUI_LISTVIEW02) - 1 Then _GUICtrlListView_SetColumnWidth($hGUI_LISTVIEW02, $i, $LVSCW_AUTOSIZE_USEHEADER) ExitLoop EndIf _GUICtrlListView_SetColumnWidth($hGUI_LISTVIEW02, $i, 70) Next EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func _Edit_Changed($hGUI_COMBOBOX) _GUICtrlComboBox_AutoComplete($hGUI_COMBOBOX) EndFunc Func AssignLV() Local $aTempView For $x = 1 To 12 $aTempView = $aListView[$x] ReDim $aTempView[Random(4, 30)][6] For $y = 0 To UBound($aTempView) - 1 $aTempView[$y][0] = $x & '-' & $y & 'A' $aTempView[$y][1] = $x & '-' & $y & 'B' $aTempView[$y][2] = $x & '-' & $y & 'C' $aTempView[$y][3] = $x & '-' & $y & 'D' $aTempView[$y][4] = $x & '-' & $y & 'E' $aTempView[$y][5] = $x & '-' & $y & 'F' Next $aListView[$x] = $aTempView Next EndFunc func On_Exit() msgbox(0,'','Bye',1) Exit endfunc kylomas Edited December 24, 2016 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Subz Posted December 24, 2016 Share Posted December 24, 2016 @kylomas You might be getting confused with Hobbyist #9 post and my last post above, as I removed the OnEvent mode. From my understanding of Hobbyist #9 post is that while you are typing in the ComboBox if you press {Enter} it should autocomplete the Combo Item and that should update the ListView, basically the same as pressing {TAB}. I found the only way to capture the {Enter} (within the ComboBox only) was to add the _IsPressed('0D') and Send a {Tab} from WM_Command. If you test #11 post you'll see what I mean, the Send function isn't really related to the GUI we are just assigning {Tab} to {Enter}, if you know of a better way I'm always willing to learn. Link to comment Share on other sites More sharing options...
careca Posted December 24, 2016 Share Posted December 24, 2016 Here's a different approach: expandcollapse popup#include <Array.au3> #include <Array.au3> #include <ButtonConstants.au3> #include <ColorConstants.au3> #include <ComboConstants.au3> #include <Date.au3> #include <EditConstants.au3> #include <File.au3> #include <GUIComboBox.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <GuiListView.au3> #include <ListViewConstants.au3> #include <Misc.au3> #include <MsgBoxConstants.au3> #include <StaticConstants.au3> #include <String.au3> #include <WindowsConstants.au3> #include <StringConstants.au3> #include <FileConstants.au3> #include <GuiTab.au3> #include <GuiButton.au3> #include <GuiMenu.au3> #include <WinAPI.au3> #include <Constants.au3> #include <WinAPIFiles.au3> #include <GuiDateTimePicker.au3> #include <Sound.au3> #include <GuiScrollBars.au3> ;I know I don't need all the above, its just a template that I throw everything into so I can move along each time ;Looking to create seris of Listviews but ONLY ONE is viewable at a time ;thought the array would be the place to store the needed data to CHANGE STATE depending upon any button I would put on it. Global $ListAll[13][2] $ListAll[0][0] = "ControlID" $ListAll[0][1] = "Handle" Local $matrix[8][18] = [[0, "$List1", "$List2", "$List3", "$List4", "$List5", "$List6", "$List7", "$List8", "$List9", _ "$List12", "$List13", "$List100", "$Button4", "$Button12", "$Button13", "$Button14", "$Button15"], _ ["Hide", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ["Show", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], _ ["Enable", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ["disABLE", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ["Checked", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], _ ["Unchecked", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ["ControlID", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]] ;_ArrayDisplay($matrix, "LABELS") ;update for state in column 0; for later, not the issue with WINAPI $matrix[1][0] = $GUI_HIDE $matrix[2][0] = $GUI_SHOW $matrix[3][0] = $GUI_ENABLE $matrix[4][0] = $GUI_DISABLE $matrix[5][0] = $GUI_CHECKED $matrix[6][0] = $GUI_UNCHECKED ;_ArrayDisplay($matrix, "Update It") ; updated $main = GUICreate("Dash Board", 680, 515, 150, 100) ;height was 480 ;$Button14 = GUICtrlCreateButton("Matrix", 10, 140, 120, 33) ;load the listviews ;GUICtrlSetState($Button14, $GUI_enABLE) ;GUICtrlSetState($Button14, $GUI_show) ;GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") ;GUICtrlSetColor(-1, 0xFF0000) ;GUICtrlSetBkColor(-1, 0xE3E3E3) ;GUICtrlSetState($Button14, $GUI_FOCUS) Local $Show = 0 GUISetState(@SW_SHOW) GUISetState() _SeeAll() While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit ;Case $Button14 ; _SeeAll() EndSwitch If _IsPressed('01') Then Sleep(50) CheckClick() EndIf Sleep(50) WEnd ;============================================================================= Func CheckClick() $Cur = GUIGetCursorInfo($main) If $Cur[4] <> 0 Then For $u = 3 To 14 If $u = $Cur[4] Then If $Show = 1 Then GetBack() ExitLoop Else GUICtrlSetState($u, $GUI_SHOW) $Show = 1 EndIf Else GUICtrlSetState($u, $GUI_HIDE) EndIf Next EndIf EndFunc ;==>CheckClick ;============================================================================= Func GetBack() For $u = 3 To 14 GUICtrlSetState($u, $GUI_SHOW) Next $Show = 0 EndFunc ;==>GetBack ;============================================================================= Func _SeeAll(); create all listviews for viewing before any selection For $i = 4 To 15 GUICtrlDelete($i) Next $j = 40 GUISetState(@SW_LOCK) For $i = 1 To 12 $ListAll[$i][0] = GUICtrlCreateListView("$ListAll" & $i, 154, $j, 500, 200) $ListAll[$i][1] = GUICtrlGetHandle($ListAll[$i][0]) _GUICtrlListView_SetExtendedListViewStyle($ListAll, BitOR($LVS_EX_HEADERDRAGDROP, $LVS_EX_GRIDLINES)) _GUICtrlListView_AddColumn($ListAll[$i][0], "A", 70) _GUICtrlListView_AddColumn($ListAll[$i][0], "B", 70) _GUICtrlListView_AddColumn($ListAll[$i][0], "C", 70) _GUICtrlListView_AddColumn($ListAll[$i][0], "D", 70) _GUICtrlListView_AddColumn($ListAll[$i][0], "E", 70) _GUICtrlListView_AddColumn($ListAll[$i][0], "F", 70) GUICtrlSetFont(-1, 8.5, 700, 0, "MS Ariel") GUICtrlSetBkColor($ListAll[$i][0], $COLOR_aqua) GUICtrlSetFont(-1, 8.5, 700, 0, "MS Ariel") GUICtrlSetState($ListAll[$i][0], $matrix[2][0]); GUICtrlSetState($ListAll[$i][0], $matrix[3][0]) $matrix[2][$i] = 1 $matrix[3][$i] = 1 $j = $j + 30 Next GUISetState(@SW_UNLOCK) ;_ArrayDisplay($ListAll, " listview array") ; controlID column 0, handle column 1 EndFunc ;==>_SeeAll Click the same to show the hidden ones, no deleting ids anymore. Hobbyist 1 Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
kylomas Posted December 24, 2016 Share Posted December 24, 2016 (edited) Subz, You're right, I used the code in #9. This thread seems to be related to this thread. I'm having trouble making heads or tails of either of the threads or what the OP wants. Good luck and Merry Xmas! kylomas Subz - F.Y.I. another way to handle autocomplete by monitoring $CBN_EDITCHANGE expandcollapse popup; ; ; #include <GuiComboBox.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $cCombo1, $cCombo2 _Main() Func _Main() ; Create GUI GUICreate("ComboBox Auto Complete", 400, 296) $cCombo1 = GUICtrlCreateCombo("", 2, 2, 396, 296) GUICtrlSetData(-1, "Apple|Orange|Tomato") $cCombo2 = GUICtrlCreateCombo("", 2, 42, 396, 296) GUICtrlSetData(-1, "One|Two|Three") GUISetState() GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>_Main Func _Edit_Changed($cCombo) _GUICtrlComboBox_AutoComplete($cCombo) EndFunc ;==>_Edit_Changed Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $ilParam $iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word $iCode = BitShift($iwParam, 16) ; Hi Word If $iCode = $CBN_EDITCHANGE Then Switch $iIDFrom Case $cCombo1 _Edit_Changed($cCombo1) Case $cCombo2 _Edit_Changed($cCombo2) EndSwitch EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Edited December 24, 2016 by kylomas Hobbyist 1 Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Hobbyist Posted December 24, 2016 Author Share Posted December 24, 2016 @subz , @ kylomas This thread is getting traction. I seemed to get nowhere in the other thread. The info here is great. Subz, yes you're posted code in #11 did the Enter key as I was seeking. Kylomas, i tried your corrected code of my attempt at accelerating keys and could not get it to work when using the Enter key. i simply copy and pasted your code and tried it as is. Did it work for you. So as a new person, I now see two solutions to the Enter key in order to get the desired result. That is great and I truly want to learn both. Other than the Enter key issue, the responses in this thread have been spot on. Thanks and yes, Merry Christmas Hobbyist Link to comment Share on other sites More sharing options...
Subz Posted December 25, 2016 Share Posted December 25, 2016 Kylomas Thanks, I'm currently using $CBN_EDITCHANGE for AutoComplete (see Post# 11), this works fine. Hobbyist just wanted to change the current behavior which initializes $CBN_SELCHANGE when typing into the AutoComplete ComboBox, normally this would be done by pressing the {Tab} key which will then update the ListViews. Hobbyist was hoping to use {Enter} key as well {Tab} to complete the string typed and initialize the $CBN_SELCHANGE. Hope that makes sense. Hobbyist Here is an updated version of Kylomas code using the OnEventMode which does the same as my code: Hope you all have a Merry Christmas. expandcollapse popup#include <Array.au3> #include <ColorConstants.au3> #include <GuiComboBox.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <ListViewConstants.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> Global $hGUI Global $hGUI_COMBOBOX01, $hGUI_COMBOBOX02 Global $hGUI_LISTVIEW01, $hGUI_LISTVIEW02 Global $aListView01[1][6], $aListView02[1][6], $aListView03[1][6], $aListView04[1][6], $aListView05[1][6], $aListView06[1][6], $aListView07[1][6], $aListView08[1][6], $aListView09[1][6], $aListView10[1][6], $aListView11[1][6], $aListView12[1][6] Global $aComboBox[13] = [12, 'ListView 01', 'ListView 02', 'ListView 03', 'ListView 04', 'ListView 05', 'ListView 06', 'ListView 07', 'ListView 08', 'ListView 09', 'ListView 10', 'ListView 11', 'ListView 12'] Global $aListView[13] = [12, $aListView01, $aListView02, $aListView03, $aListView04, $aListView05, $aListView06, $aListView07, $aListView08, $aListView09, $aListView10, $aListView11, $aListView12] Opt("GUIOnEventMode", 1) AssignLV() Example() ;///////////////////////////////////////////////// Func _submitbtn() ; call function after _Edit_Changed($hWND_GETFOCUS) to populate the listview like the current click selection Local $hWND_GETFOCUS = ControlGetFocus($hGUI) ConsoleWrite($hWND_GETFOCUS & @CRLF) Switch $hWND_GETFOCUS Case 'Edit1' If _GUICtrlComboBox_SelectString($hGUI_COMBOBOX01, GUICtrlRead($hGUI_COMBOBOX01)) >= 0 Then _GUICtrlListView_DeleteAllItems($hGUI_LISTVIEW01) $iGUI_COMBOBOX = _GUICtrlComboBox_GetCurSel($hGUI_COMBOBOX01) + 1 _GUICtrlListView_AddArray($hGUI_LISTVIEW01, $aListView[$iGUI_COMBOBOX]) For $i = 0 To _GUICtrlListView_GetColumnCount($hGUI_LISTVIEW01) - 1 If $i = _GUICtrlListView_GetColumnCount($hGUI_LISTVIEW01) - 1 Then _GUICtrlListView_SetColumnWidth($hGUI_LISTVIEW01, $i, $LVSCW_AUTOSIZE_USEHEADER) ExitLoop EndIf _GUICtrlListView_SetColumnWidth($hGUI_LISTVIEW01, $i, 70) Next EndIf Case 'Edit2' If _GUICtrlComboBox_SelectString($hGUI_COMBOBOX02, GUICtrlRead($hGUI_COMBOBOX02)) >= 0 Then _GUICtrlListView_DeleteAllItems($hGUI_LISTVIEW02) $iGUI_COMBOBOX = _GUICtrlComboBox_GetCurSel($hGUI_COMBOBOX02) + 1 _GUICtrlListView_AddArray($hGUI_LISTVIEW02, $aListView[$iGUI_COMBOBOX]) For $i = 0 To _GUICtrlListView_GetColumnCount($hGUI_LISTVIEW02) - 1 If $i = _GUICtrlListView_GetColumnCount($hGUI_LISTVIEW02) - 1 Then _GUICtrlListView_SetColumnWidth($hGUI_LISTVIEW02, $i, $LVSCW_AUTOSIZE_USEHEADER) ExitLoop EndIf _GUICtrlListView_SetColumnWidth($hGUI_LISTVIEW02, $i, 70) Next EndIf EndSwitch EndFunc ;/////////////////////////////////////////////// Func Example() $hGUI = GUICreate("Dash Board", 510, 480, 150, 100) ; to allow the gui to close with the systm control ("x") GUISetOnEvent($GUI_EVENT_CLOSE, "On_Exit") $hGUI_COMBOBOX01 = GUICtrlCreateCombo("", 5, 5, 250, 20) GUICtrlSetData($hGUI_COMBOBOX01, _ArrayToString($aComboBox, '|', 1)) $hGUI_LISTVIEW01 = GUICtrlCreateListView('Column A|Column B|Column C|Column D|Column E|Column F', 5, 30, 500, 200, '', BitOR($LVS_EX_HEADERDRAGDROP, $LVS_EX_GRIDLINES)) GUICtrlSetFont($hGUI_LISTVIEW01, 8.5, 700, 0, "MS Ariel") GUICtrlSetBkColor($hGUI_LISTVIEW01, $COLOR_aqua) $hGUI_COMBOBOX02 = GUICtrlCreateCombo("", 5, 250, 250, 20) GUICtrlSetData($hGUI_COMBOBOX02, _ArrayToString($aComboBox, '|', 1)) $hGUI_LISTVIEW02 = GUICtrlCreateListView('Column A|Column B|Column C|Column D|Column E|Column F', 5, 275, 500, 200, '', BitOR($LVS_EX_HEADERDRAGDROP, $LVS_EX_GRIDLINES)) GUICtrlSetFont($hGUI_LISTVIEW02, 8.5, 700, 0, "MS Ariel") GUICtrlSetBkColor($hGUI_LISTVIEW02, $COLOR_TEAL) ; accelerator key is associated with a control, therefore after the gui is created... local $dummy01 = GUICtrlCreateDummy() GUICtrlSetOnEvent($dummy01, "_submitbtn") Dim $AccelKeys[1][2]=[["{Enter}", $dummy01]] GUISetAccelerators($AccelKeys) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") while 1 sleep(10) wend EndFunc Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode, $iGUI_COMBOBOX $hWndFrom = $lParam $iIDFrom = BitAND($wParam, 0xFFFF) $iCode = BitShift($wParam, 16) Switch $iIDFrom Case $hGUI_COMBOBOX01 Switch $iCode Case $CBN_EDITCHANGE _Edit_Changed($hGUI_COMBOBOX01) Case $CBN_SELENDCANCEL, $CBN_SELCHANGE If _GUICtrlComboBox_SelectString($hGUI_COMBOBOX01, GUICtrlRead($hGUI_COMBOBOX01)) >= 0 Then _GUICtrlListView_DeleteAllItems($hGUI_LISTVIEW01) $iGUI_COMBOBOX = _GUICtrlComboBox_GetCurSel($hGUI_COMBOBOX01) + 1 _GUICtrlListView_AddArray($hGUI_LISTVIEW01, $aListView[$iGUI_COMBOBOX]) For $i = 0 To _GUICtrlListView_GetColumnCount($hGUI_LISTVIEW01) - 1 If $i = _GUICtrlListView_GetColumnCount($hGUI_LISTVIEW01) - 1 Then _GUICtrlListView_SetColumnWidth($hGUI_LISTVIEW01, $i, $LVSCW_AUTOSIZE_USEHEADER) ExitLoop EndIf _GUICtrlListView_SetColumnWidth($hGUI_LISTVIEW01, $i, 70) Next EndIf EndSwitch Case $hGUI_COMBOBOX02 Switch $iCode Case $CBN_EDITCHANGE _Edit_Changed($hGUI_COMBOBOX02) Case $CBN_SELENDCANCEL, $CBN_SELCHANGE If _GUICtrlComboBox_SelectString($hGUI_COMBOBOX02, GUICtrlRead($hGUI_COMBOBOX02)) >= 0 Then _GUICtrlListView_DeleteAllItems($hGUI_LISTVIEW02) $iGUI_COMBOBOX = _GUICtrlComboBox_GetCurSel($hGUI_COMBOBOX02) + 1 _GUICtrlListView_AddArray($hGUI_LISTVIEW02, $aListView[$iGUI_COMBOBOX]) For $i = 0 To _GUICtrlListView_GetColumnCount($hGUI_LISTVIEW02) - 1 If $i = _GUICtrlListView_GetColumnCount($hGUI_LISTVIEW02) - 1 Then _GUICtrlListView_SetColumnWidth($hGUI_LISTVIEW02, $i, $LVSCW_AUTOSIZE_USEHEADER) ExitLoop EndIf _GUICtrlListView_SetColumnWidth($hGUI_LISTVIEW02, $i, 70) Next EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func _Edit_Changed($hGUI_COMBOBOX) _GUICtrlComboBox_AutoComplete($hGUI_COMBOBOX) EndFunc Func AssignLV() Local $aTempView For $x = 1 To 12 $aTempView = $aListView[$x] ReDim $aTempView[Random(4, 30)][6] For $y = 0 To UBound($aTempView) - 1 $aTempView[$y][0] = $x & '-' & $y & 'A' $aTempView[$y][1] = $x & '-' & $y & 'B' $aTempView[$y][2] = $x & '-' & $y & 'C' $aTempView[$y][3] = $x & '-' & $y & 'D' $aTempView[$y][4] = $x & '-' & $y & 'E' $aTempView[$y][5] = $x & '-' & $y & 'F' Next $aListView[$x] = $aTempView Next EndFunc func On_Exit() msgbox(0,'','Bye',1) Exit endfunc Link to comment Share on other sites More sharing options...
Hobbyist Posted December 28, 2016 Author Share Posted December 28, 2016 careca, kylomas, subz All very helpful and enlightening. Thanks to everyone. Hobbyist 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