jimmy123j Posted December 22, 2018 Posted December 22, 2018 (edited) I wan't to use the ListView to create a option table for right click, and get the item or subitem text for specific target I use the _GUIListViewEx_ContextPos(), but can't get the row and col, always show the -1 and -1 expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <AutoItConstants.au3> #include <StaticConstants.au3> #include <EditConstants.au3> #include <File.au3> #include <Misc.au3> #include <String.au3> #include <Array.au3> #include "GUIListViewEx.au3" $GUI = GUICreate("Test", 500, 400) $LV = GUICtrlCreateListView("1|2|3", 1, 1, 468, 398) For $i = 1 to 9 GUICtrlCreateListViewItem ("1" & $i & "|2" & $i & "|3" & $i , $LV) Next $mContextmenu = GUICtrlCreateContextMenu($LV) $GetPos = GUICtrlCreateMenuItem("Get Pos", $mContextmenu) GUICtrlCreateMenuItem("", $mContextmenu) $TestA= GUICtrlCreateMenuItem("A", $mContextmenu) $TestB= GUICtrlCreateMenuItem("B", $mContextmenu) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $GetPos $Pos = _GUIListViewEx_ContextPos() _ArrayDisplay($Pos) EndSwitch WEnd Edited December 22, 2018 by jimmy123j
Moderators Melba23 Posted December 22, 2018 Moderators Posted December 22, 2018 jimmy123j, For the UDF to provide you with the correct information, you need to initialise the ListView so the UDF can access its details and register the UDF with Windows so it can detect the various events that the ListView generates. Then you will get the correct values: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <AutoItConstants.au3> #include <StaticConstants.au3> #include <EditConstants.au3> #include <File.au3> #include <Misc.au3> #include <String.au3> #include <Array.au3> #include "GUIListViewEx.au3" $GUI = GUICreate("Test", 500, 400) $LV = GUICtrlCreateListView("1|2|3", 1, 1, 468, 398) For $i = 1 to 9 GUICtrlCreateListViewItem ("1" & $i & "|2" & $i & "|3" & $i , $LV) Next $aLVArray = _GUIListViewEx_ReadToArray($LV) ; Convert the ListView content into an array <<<<<<<<<< $iLVIndex = _GUIListViewEx_Init($LV, $aLVArray) ; Initialise the UDF using that array <<<<<<<<<<<<< $mContextmenu = GUICtrlCreateContextMenu($LV) $GetPos = GUICtrlCreateMenuItem("Get Pos", $mContextmenu) GUICtrlCreateMenuItem("", $mContextmenu) $TestA= GUICtrlCreateMenuItem("A", $mContextmenu) $TestB= GUICtrlCreateMenuItem("B", $mContextmenu) GUISetState() _GUIListViewEx_MsgRegister() ; Register the Windows messages used by the UDF <<<<<<<<<<<<<<<<<<<<<< While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $GetPos $Pos = _GUIListViewEx_ContextPos() ; Now this function will return the correct values <<<< _ArrayDisplay($Pos) EndSwitch WEnd Please ask if you have any questions. M23 P.S. And if you have any further questions about any of my UDFs, please post in the relevant UDF thread (they are listed in my sig). 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 December 24, 2018 Author Posted December 24, 2018 On 2018/12/22 at 11:56 PM, Melba23 said: jimmy123j, For the UDF to provide you with the correct information, you need to initialise the ListView so the UDF can access its details and register the UDF with Windows so it can detect the various events that the ListView generates. Then you will get the correct values: Please ask if you have any questions. M23 P.S. And if you have any further questions about any of my UDFs, please post in the relevant UDF thread (they are listed in my sig). Thank you M23, it's work now When my code not work, I try to edit the code from the Example 6, but still in-vain Can I ask other stupid questions ? If I want to disable move the row selected, how can I do 'cause user might move the row when they click the list, and I find all function of the UDF, but still can't find it Sorry for stupid question and thanks again !
Moderators Melba23 Posted December 24, 2018 Moderators Posted December 24, 2018 jimmy123j, Glad your code works now. To prevent drag, just tell the UDF not to allow it - like this: $iLVIndex = _GUIListViewEx_Init($LV, $aLVArray, 0, 0, Default, 512) Look in the _GUIListViewEx_Init function header to see what the various parameters do - and why 512 is what you need. M23 P.S. And once again, if you have any further questions about any of my UDFs, please post in the relevant UDF thread (they are listed in my sig). 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