Abraham Posted February 23, 2024 Posted February 23, 2024 (edited) Hello everyone, I hope you’re all doing well. Could someone please assist me with the GUIListViewEx UDF? I’m struggling to get the Switch @extended to work with multiple GUIs, this is an example of what I want to achieve expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> #include "GUIListViewEx.au3" Global $g_hGUI1, $g_idButton1, $g_hGUI2, $g_idButton3 example() Func example() gui1() Local $aMsg _GUIListViewEx_MsgRegister() While 1 $aMsg = GUIGetMsg(1) ; Use advanced parameter to get array If Not IsHWnd($aMsg[1]) Then ContinueLoop ; preventing subsequent lines from processing when nothing happens Switch $aMsg[1] ; check which GUI sent the message Case $g_hGUI1 Switch $aMsg[0] ; Now check for the messages for $g_hGUI1 Case $GUI_EVENT_CLOSE ; If we get the CLOSE message from this GUI: $g_hGUI1 ... ExitLoop ; ... exit the loop and thus exit the program Case $g_idButton1 GUICtrlSetState($g_idButton1, $GUI_DISABLE) gui2() EndSwitch Case $g_hGUI2 Switch $aMsg[0] ; Now check for the messages for $g_hGUI2 Case $GUI_EVENT_CLOSE ; If we get the CLOSE message from this GUI : $g_hGUI2 ... GUIDelete($g_hGUI2) ; ... just delete the GUI ... GUICtrlSetState($g_idButton1, $GUI_ENABLE) ; ... enable button (previously disabled) EndSwitch EndSwitch $vRet = _GUIListViewEx_EventMonitor() If @error Then MsgBox($MB_SYSTEMMODAL, "Error", "Event error: " & @error) EndIf Switch @extended Case 0 ; No event detected Case 4 MsgBox($MB_SYSTEMMODAL, "Dragged", "From:To" & @CRLF & $vRet & @CRLF) EndSwitch WEnd EndFunc ;==>example Func gui1() $g_hGUI1 = GUICreate("GUI 1", 200, 200, 100, 100) $g_idButton1 = GUICtrlCreateButton("Show GUI 2", 10, 60, 80, 30) GUISetState() EndFunc ;==>gui1 Func gui2() $g_hGUI2 = GUICreate("GUI 2", 400, 600, 350, 350) ; Create ListViews $cLV_Tom = GUICtrlCreateListView("Tom",10, 30, 180, 160) _GUICtrlListView_SetColumnWidth($cLV_Tom, 0, 140) $cLV_Dick = GUICtrlCreateListView("Dick",210, 30, 180, 160) _GUICtrlListView_SetColumnWidth($cLV_Dick, 0, 140) $cLV_Harry = GUICtrlCreateListView("Harry",10, 230, 180, 160) _GUICtrlListView_SetColumnWidth($cLV_Harry, 0, 140) $cLV_Fred = GUICtrlCreateListView("Fred",210, 230, 180, 160) _GUICtrlListView_SetColumnWidth($cLV_Fred, 0, 140) $cLV_Dora = GUICtrlCreateListView("Dora",10, 430, 180, 160) _GUICtrlListView_SetColumnWidth($cLV_Dora, 0, 140) ; Create arrays and fill ListViews Global $aTom[5], $aDick[5], $aHarry[5], $aFred[5], $aDora[5] For $i = 0 To 4 $aTom[$i] = "Tom " & $i GUICtrlCreateListViewItem($aTom[$i], $cLV_Tom) $aDick[$i] = "Dick " & $i GUICtrlCreateListViewItem($aDick[$i], $cLV_Dick) $aHarry[$i] = "Harry " & $i GUICtrlCreateListViewItem($aHarry[$i], $cLV_Harry) $aFred[$i] = "Fred " & $i GUICtrlCreateListViewItem($aFred[$i], $cLV_Fred) $aDora[$i] = "Dora " & $i GUICtrlCreateListViewItem($aDora[$i], $cLV_Dora) Next GUISetState() EndFunc ;==>gui2 Any help would be greatly appreciated. Thank you. Edited February 23, 2024 by Abraham
Moderators Melba23 Posted February 24, 2024 Moderators Posted February 24, 2024 (edited) Abraham, You need to initialise the ListViews so that the UDF knows that it needs to follow them. Add these lines before returning from function gui2: $iLV_Tom = _GUIListViewEx_Init($cLV_Tom,$aTom) $iLV_Dick = _GUIListViewEx_Init($cLV_Dick,$aDick) $iLV_Harry = _GUIListViewEx_Init($cLV_Harry,$aHarry) $iLV_Fred = _GUIListViewEx_Init($cLV_Fred,$aFred) $iLV_Dora = _GUIListViewEx_Init($cLV_Dora,$aDora) And do remember to _Close the ListViews when you delete the GUI which holds them to free up the UDF ready for the next time you create the GUI. M23 Edited February 24, 2024 by Melba23 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
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