Moderators Melba23 Posted August 9, 2021 Author Moderators Posted August 9, 2021 jimmy123j, Quote I can't share original script With a UDF as complex as this one it is pretty much impossible to debug without sight of the actual script. So I do not think I can offer any more help as I have no clues on which to base any debugging - sorry. But I would suggest double-checking the naming of any variables associated with the various ListViews to see if there is a similar misspelling to the one in your example script. 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
jimmy123j Posted August 9, 2021 Posted August 9, 2021 (edited) Hi Melba23, thanks for reply (the sample script has same flow logic with original script, I just remove the not important code) I already changed the Listview Index to right part of the example script, and still got fail as I replied I try the new ver. and fixed script variable, still fail And I add the button return the Listview Index 1/2, maybe can help you check the issue (as gif pic.) thanks reply my issue and debug, ListviewEx script is very useful for me, thanks again !! Fixed Script Gif Pic. (still fail) New Script expandcollapse popup; =========================================================================================================================================== #include <Array.au3> #include <Date.au3> #include <File.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <StaticConstants.au3> #include <GuiStatusBar.au3> #include <WindowsConstants.au3> #include <GuiDateTimePicker.au3> #include <GuiListView.au3> #include <GUIListViewEx.au3> #include <ListViewConstants.au3> ; =========================================================================================================================================== Global $Tool_Temp Global $List_Default_Color[5] = ["", "", "0xFFFFFF", "0xFFA247", "0xFF00FF"] ; =========================================================================================================================================== $Main_UI = GUICreate("Window 1", 550, 300, -1, -1, $WS_SIZEBOX + $WS_MINIMIZEBOX) GUISetBkColor(0xFFFFFF, $Main_UI) ; =========================================================================================================================================== Global $Window1_List, $Window1_Array, $Window1_Index $Windows1_Button_1 = GUICtrlCreateButton("Step 1", 430, 110, 100, 30) $Windows1_Button_2 = GUICtrlCreateButton("Step 2", 430, 50, 100, 30) $Windows_Chek = GUICtrlCreateButton("Check Index", 430, 180, 100, 30) $Window1_List = GUICtrlCreateListView("AAAA|BBBB|CCCC|DDDD", 0, 20, 400, 200, $LVS_REPORT + $LVS_SINGLESEL, $LVS_EX_FULLROWSELECT + $WS_EX_CLIENTEDGE) _GUICtrlListView_SetCallBackMask($Window1_List, 4) ; =========================================================================================================================================== Global $Window2_List,$Window2_Array, $Window2_Index $Window2_UI = GUICreate("2nd Windows", 400, 200, -1, -1, $WS_SIZEBOX, -1, $Main_UI) $Window2_List = GUICtrlCreateListView("Item 1|Item 2|Item 3|Item 4|Item 5", 0, 0, 400, 200, $LVS_REPORT + $LVS_SINGLESEL, $LVS_EX_FULLROWSELECT + $WS_EX_CLIENTEDGE) $Window2_Menu = GUICtrlCreateContextMenu($Window2_List) $Window2_Edit = GUICtrlCreateMenuItem("Edit", $Window2_Menu) _GUICtrlListView_SetCallBackMask($Window2_List, 4) ; =========================================================================================================================================== _GUIListViewEx_MsgRegister() GUISetState(@SW_SHOW, $Main_UI) ; =========================================================================================================================================== While 1 ; ======================================================================================================================================== $UIGet = GUIGetMsg(1) Switch $UIGet[1] ; ================================================================================================================================== Case $Main_UI Switch $UIGet[0] Case $GUI_EVENT_CLOSE ExitLoop Case $Windows1_Button_2 Windows1_Script() Case $Windows1_Button_1 Windows2_Script() GUISetState(@SW_SHOW, $Window2_UI) Case $Windows_Chek MsgBox(0, "", "Listview 1 Index : " & $Window1_Index & @CRLF & @CRLF & "Listview 2 Index : " & $Window2_Index) EndSwitch ; ================================================================================================================================== Case $Window2_UI Switch $UIGet[0] Case $GUI_EVENT_CLOSE GUISetState(@SW_HIDE, $Window2_UI) Case $Window2_Edit $Tool_Temp = StringSplit(_GUIListViewEx_GetLastSelItem($Window2_Index), "|") _GUIListViewEx_EditItem($Tool_Temp[1], $Tool_Temp[2], $Tool_Temp[3]) EndSwitch EndSwitch ; ======================================================================================================================================== Sleep(25) WEnd Exit ; =========================================================================================================================================== Func Windows1_Script() Local $First_Array[2][5] = [[1, 2, 3, 4, 5],[6, 7, 8, 9, 10]] _GUIListViewEx_Close($Window1_Index) _GUICtrlListView_DeleteAllItems($Window1_List) _GUICtrlListView_AddArray($Window1_List, $First_Array) $Window1_Index = _GUIListViewEx_Init($Window1_List, $First_Array, 0, Default, False, 1 + 32 + 512) _GUIListViewEx_SetDefColours($Window1_Index, $List_Default_Color) EndFunc Func Windows2_Script() Local $lsms_Array[2][5] = [[1, 2, 3, 4, 5],[6, 7, 8, 9, 10]] _GUIListViewEx_Close($Window2_Index) _GUICtrlListView_DeleteAllItems($Window2_List) _GUICtrlListView_AddArray($Window2_List, $lsms_Array) $Window2_Index = _GUIListViewEx_Init($Window2_List, $lsms_Array, 0, Default, False, 1 + 2 + 32 + 512 + 1024) _GUIListViewEx_SetDefColours($Window2_Index, $List_Default_Color) EndFunc Edited August 9, 2021 by jimmy123j
Moderators Melba23 Posted August 9, 2021 Author Moderators Posted August 9, 2021 (edited) jimmy123j, OK, I can reproduce the problem and know what is happening. Now I need to see why it happens! M23 I think I have found the solution - try this code and see if it works for you too: GUIListViewEx_Test.au3 Edited August 9, 2021 by Melba23 jimmy123j and robertocm 2 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
jimmy123j Posted August 10, 2021 Posted August 10, 2021 (edited) Hi Melba23, It's work OMG 😃 I'll try this Test ver. on my original script, and feedback tomorrow, Thanks !!! Edited August 10, 2021 by jimmy123j
Moderators Melba23 Posted August 10, 2021 Author Moderators Posted August 10, 2021 jimmy123j, Quote It's work OMG Delighted to hear it. Waiting for confirmation from your main script. 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
jimmy123j Posted August 11, 2021 Posted August 11, 2021 (edited) 8 hours ago, Melba23 said: Delighted to hear it. Waiting for confirmation from your main script. Sorry for wait, the original script works fine with test ver. and Listview index can be distributed the right index number (not duplicate) the test ver. already solved the index duplicate problem (I though), maybe can update into next AU3 release ver. if any issue in future, I'll keep feedback to you thanks for waste your time to help the issue, your AU3 is really awesome and useful !! Edited August 11, 2021 by jimmy123j
Moderators Melba23 Posted August 11, 2021 Author Moderators Posted August 11, 2021 jimmy123j, Great news. I will release a new version as soon as novel confirms that the changes I made for him last week are working correctly. Thanks to you for reporting the problem and testing the changes. 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
jimmy123j Posted August 11, 2021 Posted August 11, 2021 (edited) 1 hour ago, Melba23 said: jimmy123j, Great news. I will release a new version as soon as novel confirms that the changes I made for him last week are working correctly. Thanks to you for reporting the problem and testing the changes. M23 Sorry, me again I just try the main script, and _GUIListViewEx_LoadColour seems not work, but _GUIListViewEx_SetColour is work I used the _GUIListViewEx_ReturnArray to load the _GUIListViewEx_SetColour color array compare to _GUIListViewEx_LoadColour used color array are same And I check the mssage return by _GUIListViewEx_LoadColour is success maybe need to confirm the test ver. with new index distribution, Thanks !!! Edited August 11, 2021 by jimmy123j
Moderators Melba23 Posted August 11, 2021 Author Moderators Posted August 11, 2021 jimmy123j, Quote maybe need to confirm the test ver. with new index distribution Almost certainly you will need to do this to get the colouring working correctly as it depends on the indexing being correct. Keeping my fingers crossed! 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
NassauSky Posted September 7, 2021 Posted September 7, 2021 (edited) Hi @Melba23 I'm trying to integrate your _GUIListViewEx into a large application and keep getting the following error: (5499) : ==> Array variable has incorrect number of subscripts I'm mainly using it for dragging and dropping rows. It works fine until I add a row. I had the thought that maybe I needed to add the following initalization each time I added an item to the listview: $iLV = _GUIListViewEx_Init($XpathEditCode, "", 0, 0, True) but that didn't seem to help so I then added the following line after each init where I saw that items were added to the listview: _GUIListViewEx_MsgRegister(False,True,True,True) ; Since I have my own WM_NOTIFY message which didn't help either and that wouldn't make sense that I'd have to register the message each time so I removed that last line except for the first instance after i create the blank listview. Without having to dig through the large app for just the sections that's related, can you maybe provide some pointers as to what might be causing the issue. Alternatively is there maybe my own initialization I can add to the UDF to always check for updates to the listview? Make sense? Thanks for any direction. Edited September 7, 2021 by NassauSky
Moderators Melba23 Posted September 7, 2021 Author Moderators Posted September 7, 2021 NassauSky, At a guess you are adding elements to the ListView using the standard functions rather than using the UDF _GUIListViewEx_Insert/InsertSpec functions. That would mean that the ListView contents no longer match the internal shadow array within the UDF - which usually ends in tears and an error like the one you describe. So how do you add the new rows? 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
NassauSky Posted September 7, 2021 Posted September 7, 2021 @Melba23 Oh great you might have hit jackpot. I'm using GUICtrlListView_InsertItem so i have to compare that to your function to see what I need to change. Crossing fingers.
NassauSky Posted September 7, 2021 Posted September 7, 2021 (edited) Hmmmm @Melba23 OK getting very close. I wasn't expecting _GUIListViewEx_InsertSpec to be different as far as including the option for the index.... OK got a basic example that I'm going to try to integrate: #Include ".\Required\GUIListViewEx.au3" #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> ; Create GUI $hGUI = GUICreate("LVEx Example 1", 640, 510) Global $hListView_Right = _GUICtrlListView_Create($hGUI, "", 430, 40, 200, 300, BitOR($LVS_DEFAULT, $WS_BORDER)) ;UDF version _GUICtrlListView_AddColumn($hListView_Right, "Column 1", 83) _GUICtrlListView_AddColumn($hListView_Right, "Column 2", 83) $iLV_Right_Index = _GUIListViewEx_Init($hListView_Right, "", 0, 0, True) _GUIListViewEx_MsgRegister() GUISetState() _GUIListViewEx_InsertSpec($iLV_Right_Index, 0, "Row 1a Manual Wait| Test 1b") _GUIListViewEx_InsertSpec($iLV_Right_Index, 1, "Row 2a Manual Wait| Test 2b") Sleep(3000) OK so it turns out I have to close it, delete items then reinitialize it in order to clear the listview and re-add items _GUIListViewEx_Close($iLV_Right_Index) _GUICtrlListView_DeleteAllItems($hListView_Right) $iLV_Right_Index = _GUIListViewEx_Init($hListView_Right, "", 0, 0, True) _GUIListViewEx_SetActive($iLV_Right_Index) Edited September 8, 2021 by NassauSky
NassauSky Posted September 8, 2021 Posted September 8, 2021 (edited) That's my luck. Fix one thing and another thing breaks. Got the Listview UDF to move rows even with new data added but it lost my right click menu. 😕 Got to figure that out since I was using the following before: Global $ContextMenu = GUICtrlCreateContextMenu($idListview) ;Right-Click Context menu inside Listview Local $Del = GUICtrlCreateMenuItem("Run This", $ContextMenu, 1) GUICtrlSetOnEvent(-1, "_myRoutine1") Local $Add = GUICtrlCreateMenuItem("Run That", $ContextMenu, 2) GUICtrlSetOnEvent(-1, "_myRoutine2") Any examples of how to integrate my old menu as above into your UDF? Example 6 has a right click context menu but it uses the Native functions to create the menu. Thanks maybe almost there. Edited September 8, 2021 by NassauSky
Moderators Melba23 Posted September 8, 2021 Author Moderators Posted September 8, 2021 NassauSky, Quote so it turns out I have to close it, delete items then reinitialize it in order to re-add items That does not sound right - if you use the UDF to add items then the ListView should work correctly after the insertion. Using your code from above, this works fine for me - I can drag the inserted items without problem: #Include "GUIListViewEx.au3" #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> ; Create GUI $hGUI = GUICreate("LVEx Example 1", 640, 510) Global $hListView_Right = _GUICtrlListView_Create($hGUI, "", 430, 40, 200, 300, BitOR($LVS_DEFAULT, $WS_BORDER)) ;UDF version _GUICtrlListView_AddColumn($hListView_Right, "Column 1", 83) _GUICtrlListView_AddColumn($hListView_Right, "Column 2", 83) $iLV_Right_Index = _GUIListViewEx_Init($hListView_Right, "", 0, 0, True) _GUIListViewEx_MsgRegister() GUISetState() _GUIListViewEx_InsertSpec($iLV_Right_Index, 0, "Row 1a Manual Wait| Test 1b") _GUIListViewEx_InsertSpec($iLV_Right_Index, 1, "Row 2a Manual Wait| Test 2b") Sleep(5000) As to the context menu, you are using the UDF function to create the ListView ($hListView_Right = _GUICtrlListView_Create) which gives you a handle and then using a ControlID ($idListview - where does that come from?) to create the context menu. Are you sure that your code worked before? Do you really need to create the ListView using the UDF function? 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
NassauSky Posted September 8, 2021 Posted September 8, 2021 (edited) @Melba23 So yes the first example does work which you reposted in your previous post. I used that as an example when I was looking through code in my project to modify. Next step was testing some clearing and reloading of data into the listview. When I wanted to completely clear the listview, I was able to do so without it keeping any elements in the listview by following those 'clear listview' steps I noted above. If you are saying that I shouldn't clear the listview the way I displayed above each time I want to wipe all the contents and add new elements then I'll work on that after I get the context menu working. As far as the $idListview which I noted on the the above code, I guess I was hoping you'd notice and comment on that. I tried both the handle of the listview control which will host the contxt menu $hListView_Right and the returned index number $iLV_Right_Index. Are you saying that your UDF will handle creating a context menu in that fashion? The only reason I was using the UDF function was for dragging rows up or down. Thanks again. Edited September 8, 2021 by NassauSky
Moderators Melba23 Posted September 8, 2021 Author Moderators Posted September 8, 2021 NassauSky, There was a misunderstanding - if you want to completely clear and reload a ListView then what you are doing is exactly the way to do so. As to context menus - here is how to create context menus on both native and UDF-created ListViews: expandcollapse popup#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiMenu.au3> #Include "GUIListViewEx.au3" Opt("GUIOnEventMode", 1) Global Enum $iThis = 1000, $iThat ; Create GUI $hGUI = GUICreate("LVEx Example 1", 640, 510) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $cListView_Left = GUICtrlCreateListView("", 30, 40, 200, 300, BitOR($LVS_DEFAULT, $WS_BORDER)) _GUICtrlListView_AddColumn($cListView_Left, "Column 1", 83) _GUICtrlListView_AddColumn($cListView_Left, "Column 2", 83) $iLV_Left_Index = _GUIListViewEx_Init($cListView_Left, "", 0, 0, True) $ContextMenu = GUICtrlCreateContextMenu($cListView_Left) ;Right-Click Context menu inside Listview GUICtrlCreateMenuItem("Run This", $ContextMenu, 1) GUICtrlSetOnEvent(-1, "_myRoutine1") GUICtrlCreateMenuItem("Run That", $ContextMenu, 2) GUICtrlSetOnEvent(-1, "_myRoutine2") $hListView_Right = _GUICtrlListView_Create($hGUI, "", 330, 40, 200, 300, BitOR($LVS_DEFAULT, $WS_BORDER)) ;UDF version _GUICtrlListView_AddColumn($hListView_Right, "Column 1", 83) _GUICtrlListView_AddColumn($hListView_Right, "Column 2", 83) $iLV_Right_Index = _GUIListViewEx_Init($hListView_Right, "", 0, 0, True) _GUIListViewEx_MsgRegister(False) GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") GUISetState() _GUIListViewEx_InsertSpec($iLV_Left_Index, 0, "Row 1a Manual Wait| Test 1b") _GUIListViewEx_InsertSpec($iLV_Left_Index, 1, "Row 2a Manual Wait| Test 2b") _GUIListViewEx_InsertSpec($iLV_Right_Index, 0, "Row 1a Manual Wait| Test 1b") _GUIListViewEx_InsertSpec($iLV_Right_Index, 1, "Row 2a Manual Wait| Test 2b") While 1 Sleep(10) WEnd Func _Exit() Exit EndFunc Func _myRoutine1() MsgBox($MB_SYSTEMMODAL, "Native", "Running This") EndFunc Func _myRoutine2() MsgBox($MB_SYSTEMMODAL, "Native", "Running That") EndFunc Func _LV_Right_RClick() $aHit = _GUICtrlListView_SubItemHitTest($hListView_Right) If $aHit[0] <> -1 Then $hMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_AddMenuItem($hMenu, "Run This", $iThis) _GUICtrlMenu_AddMenuItem($hMenu, "Run That", $iThat) Switch _GUICtrlMenu_TrackPopupMenu($hMenu, $hListView_Right, -1, -1, 1, 1, 2) Case $iThis _myRoutine1() Case $iThat _myRoutine2() EndSwitch _GUICtrlMenu_DestroyMenu($hMenu) EndIf EndFunc Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListView_Right Switch $iCode Case $NM_RCLICK _LV_Right_RClick() Return 0 EndSwitch EndSwitch _GUIListViewEx_WM_NOTIFY_Handler($hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>WM_NOTIFY Note the requirement NOT to register the WM_NOTIFY message within the UDF _MsgRegister function, but to call the associated function within the separate registered handler. I hope that clears up all of your questions. M23 robertocm 1 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
NassauSky Posted September 8, 2021 Posted September 8, 2021 @Melba23That is excellent. Very good example. I tried adding to your example _WM_NOTIFY to find out what cell is selected in the UDF: Case $NM_RCLICK MsgBox(0,"Clicked", "Row: " & $aGLVEx_Data[0][10] & " /Column: " & $aGLVEx_Data[0][11] ) $aContextChoice=_GUIListViewEx_ContextPos() MsgBox(0,"Clicked", "Index: " & $aContextChoice[0] & " /Row: " & $aContextChoice[1] & " /Column: " & $aContextChoice[2] ) Return 0 Not as easy as I was hoping but I'm sure once again I'm overlooking something.
Moderators Melba23 Posted September 8, 2021 Author Moderators Posted September 8, 2021 NassauSky, I wrote the _GUIListViewEx_ContextPos function to do exactly that so what more were you hoping for? 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
NassauSky Posted September 8, 2021 Posted September 8, 2021 Sorry @Melba23 with minor changes this is my code which is crashing and not showing correct row & cols during right clicking on the right listview expandcollapse popup#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <GuiMenu.au3> #Include ".\Required\GUIListViewEx.au3" Opt("GUIOnEventMode", 1) Global Enum $iThis = 1000, $iThat ; Create GUI $hGUI = GUICreate("ContextMenu NATIVE vs UDF", 640, 510) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") ;--------------------------------------------------LEFT NATIVE SETUP-------------------------------------------------------------------------- $cListView_Left = GUICtrlCreateListView("", 30, 40, 200, 300, BitOR($LVS_DEFAULT, $WS_BORDER)) _GUICtrlListView_AddColumn($cListView_Left, "Column 1", 83) _GUICtrlListView_AddColumn($cListView_Left, "Column 2", 83) $iLV_Left_Index = _GUIListViewEx_Init($cListView_Left, "", 0, 0, True) $ContextMenu = GUICtrlCreateContextMenu($cListView_Left) ;Right-Click Context menu inside Listview GUICtrlCreateMenuItem("Run This", $ContextMenu, 1) GUICtrlSetOnEvent(-1, "_myRoutine1") GUICtrlCreateMenuItem("Run That", $ContextMenu, 2) GUICtrlSetOnEvent(-1, "_myRoutine2") ;-------------------------------------------------RIGHT UDF SETUP------------------------------------------------------------------------------ $hListView_Right = _GUICtrlListView_Create($hGUI, "", 330, 40, 200, 300, BitOR($LVS_DEFAULT, $WS_BORDER)) ;UDF version _GUICtrlListView_AddColumn($hListView_Right, "Column 1", 83) _GUICtrlListView_AddColumn($hListView_Right, "Column 2", 83) $iLV_Right_Index = _GUIListViewEx_Init($hListView_Right, "", 0, 0, True) _GUIListViewEx_MsgRegister(False) GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") GUISetState() ;-------------------------------------------------COMMON ITEM INSERTION------------------------------------------------------------------------- _GUIListViewEx_InsertSpec($iLV_Left_Index, 0, "Row 1a Manual Wait| Test 1b") _GUIListViewEx_InsertSpec($iLV_Left_Index, 1, "Row 2a Manual Wait| Test 2b") _GUIListViewEx_InsertSpec($iLV_Right_Index, 0, "Row 1a Manual Wait| Test 1b") _GUIListViewEx_InsertSpec($iLV_Right_Index, 1, "Row 2a Manual Wait| Test 2b") While 1 Sleep(10) WEnd Func _Exit() Exit EndFunc Func _myRoutine1() MsgBox($MB_SYSTEMMODAL, "Native", "Running This") EndFunc Func _myRoutine2() MsgBox($MB_SYSTEMMODAL, "Native", "Running That") EndFunc Func _LV_Right_RClick() ; Called inside _WM_NOTIFY $aHit = _GUICtrlListView_SubItemHitTest($hListView_Right) If $aHit[0] <> -1 Then $hMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_AddMenuItem($hMenu, "Run This", $iThis) _GUICtrlMenu_AddMenuItem($hMenu, "Run That", $iThat) Switch _GUICtrlMenu_TrackPopupMenu($hMenu, $hListView_Right, -1, -1, 1, 1, 2) Case $iThis _myRoutine1() Case $iThat _myRoutine2() EndSwitch _GUICtrlMenu_DestroyMenu($hMenu) EndIf EndFunc Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListView_Right Switch $iCode Case $NM_RCLICK ;_GUIListViewEx_SetActive(2) MsgBox(0,"Clicked", "Row: " & $aGLVEx_Data[0][10] & " /Column: " & $aGLVEx_Data[0][11] ) $aContextChoice=_GUIListViewEx_ContextPos() MsgBox(0,"Clicked", "Index: " & $aContextChoice[0] & " /Row: " & $aContextChoice[1] & " /Column: " & $aContextChoice[2] ) ;_LV_Right_RClick() ; Creates a context menu & points to routines Return 0 EndSwitch EndSwitch _GUIListViewEx_WM_NOTIFY_Handler($hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>WM_NOTIFY
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