JohnOne Posted February 26, 2015 Share Posted February 26, 2015 (edited) Originally though $LVS_EX_BORDERSELECT was breaking my script, turns out I was using it wrong. Pehaps a mention in the help file might be in order <see highlighted post> My question now boils down to the below bold. If I change the listview creation to the commented out one, it's as though the button is constantly being pressed. Also the uncommented one, only the cells in col1 can be selected, and I need to selects any in the view. Script is straight out of the help file with only the styles and exstyles added. Exit script with Esc key. expandcollapse popup#include <ListViewConstants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> HotKeySet("{Esc}", "_Exit") Example() Func Example() GUICreate("listview items", 220, 250, 100, 200, -1, $WS_EX_ACCEPTFILES) GUISetBkColor(0x00E0FFFF) ; will change background color ;Local $idListview = GUICtrlCreateListView("col1 |col2|col3 ", 10, 10, 200, 150, $LVS_SINGLESEL, BitOR($LVS_EX_BORDERSELECT, $LVS_EX_GRIDLINES)) Local $idListview = GUICtrlCreateListView("col1 |col2|col3 ", 10, 10, 200, 150, $LVS_SINGLESEL, $LVS_EX_GRIDLINES) Local $idButton = GUICtrlCreateButton("Value?", 75, 170, 70, 20) Local $idItem1 = GUICtrlCreateListViewItem("item2|col22|col23", $idListview) Local $idItem2 = GUICtrlCreateListViewItem("item1|col12|col13", $idListview) Local $idItem3 = GUICtrlCreateListViewItem("item3|col32|col33", $idListview) GUICtrlCreateInput("", 20, 200, 150) ;GUICtrlSetState(-1, $GUI_DROPACCEPTED) ; to allow drag and dropping GUISetState(@SW_SHOW) GUICtrlSetData($idItem2, "ITEM1") GUICtrlSetData($idItem3, "||COL33") GUICtrlDelete($idItem1) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idButton MsgBox($MB_SYSTEMMODAL, "listview item", GUICtrlRead(GUICtrlRead($idListview)), 2) Case $idListview MsgBox($MB_SYSTEMMODAL, "listview", "clicked=" & GUICtrlGetState($idListview), 2) EndSwitch WEnd EndFunc ;==>Example Func _Exit() Exit EndFunc Obviously looking for a solution to selecting any cell. Edited February 26, 2015 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
SadBunny Posted February 26, 2015 Share Posted February 26, 2015 Reproduced on windows 8.1. JohnOne 1 Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
JohnOne Posted February 26, 2015 Author Share Posted February 26, 2015 The button part might be a bug, but that's not important to me just now. But I've searched a lot and not found how to select a single item in a 2D list view, with the exception of column 0. My wonder at the moment is if it's even possible to that. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Solution johnmcloud Posted February 26, 2015 Solution Share Posted February 26, 2015 (edited) expandcollapse popup;~ Example made by LarsJ, just some very little change by Johnmcloud - 2015 #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> Opt("MustDeclareVars", 1) Global $hGUI, $hListview, $aHit[2] = [-1, -1] ; $aHit contains row & col of marked cell $hGUI = GUICreate("Mark Cell in Listview", 250, 222) Local $iListview = GUICtrlCreateListView("Column 0|Column 1", 2, 2, 248, 180, $LVS_REPORT, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) $$hListview = GUICtrlGetHandle($iListview) Local $iButton = GUICtrlCreateButton("Value?", 90, 193, 70, 20) For $i = 0 To 50 GUICtrlCreateListViewItem("Item" & $i & "|SubItem " & $i, $iListview) Next GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $iButton MsgBox(0, "Info", "Cell selected: " & _GUICtrlListView_GetItemText($hListview, $aHit[0], $aHit[1]) & @CR, 0, $hGUI) EndSwitch WEnd Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tNMHDR, $hWndFrom, $iCode $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListview Switch $iCode Case $LVN_ITEMCHANGED Local $tNMLISTVIEW, $iItem, $aInfo $tNMLISTVIEW = DllStructCreate($tagNMLISTVIEW, $lParam) $iItem = DllStructGetData($tNMLISTVIEW, "Item") _GUICtrlListView_SetItemSelected($hListview, $iItem, False) Local $aInfo = GUIGetCursorInfo($hGUI) If $aInfo[2] Then $aInfo = _GUICtrlListView_SubItemHitTest($hListview, $aInfo[0] - 2, $aInfo[1] - 2) ; Upper left = ( 2, 2 ) If $aInfo[0] > -1 And $aInfo[1] > -1 And $aInfo[0] = $iItem Then If $aHit[0] > -1 Then _GUICtrlListView_RedrawItems($hListview, $aHit[0], $aHit[0]) If $aHit[0] <> $aInfo[0] Or $aHit[1] <> $aInfo[1] Then $aHit[0] = $aInfo[0] ; Row $aHit[1] = $aInfo[1] ; Col Else $aHit[0] = -1 ; Row $aHit[1] = -1 ; Col EndIf _GUICtrlListView_RedrawItems($hListview, $iItem, $iItem) EndIf EndIf Case $NM_CUSTOMDRAW Local $tNMLVCUSTOMDRAW = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) Local $dwDrawStage = DllStructGetData($tNMLVCUSTOMDRAW, "dwDrawStage") Switch $dwDrawStage ; Holds a value that specifies the drawing stage Case $CDDS_PREPAINT ; Before the paint cycle begins Return $CDRF_NOTIFYITEMDRAW ; Notify the parent window of any ITEM-related drawing operations Case $CDDS_ITEMPREPAINT ; Before painting an item Return $CDRF_NOTIFYSUBITEMDRAW ; Notify the parent window of any SUBITEM-related drawing operations Case BitOR($CDDS_ITEMPREPAINT, $CDDS_SUBITEM) ; Before painting a subitem Local $dwItemSpec = DllStructGetData($tNMLVCUSTOMDRAW, "dwItemSpec") ; Item index Local $iSubItem = DllStructGetData($tNMLVCUSTOMDRAW, "iSubItem") ; Subitem index Local $uItemState = DllStructGetData($tNMLVCUSTOMDRAW, "uItemState") ; Item state If $dwItemSpec = $aHit[0] Then ; Marked row Switch $iSubItem Case $aHit[1] ; Marked column DllStructSetData($tNMLVCUSTOMDRAW, "ClrText", 0xFFFFFF) ; Forecolor white DllStructSetData($tNMLVCUSTOMDRAW, "clrTextBk", 0xCC6600) ; Backcolor dark blue, BGR Case Else ; Other columns DllStructSetData($tNMLVCUSTOMDRAW, "ClrText", 0x000000) ; Forecolor black DllStructSetData($tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF) ; Backcolor white EndSwitch Else ; Other rows DllStructSetData($tNMLVCUSTOMDRAW, "ClrText", 0x000000) DllStructSetData($tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF) EndIf Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY $LVS_EX_BORDERSELECT works only with icon Listview style, your use is wrong. Rename the thread accordy to the request, so "how to select subitem in listview" or similar. Edited February 26, 2015 by johnmcloud JohnOne 1 Link to comment Share on other sites More sharing options...
JohnOne Posted February 26, 2015 Author Share Posted February 26, 2015 Thank you very kindly johnmcloud. I was missing one simple keyword "subitem" which may have led me to a solution. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
bogQ Posted February 26, 2015 Share Posted February 26, 2015 and another interesting topicit is maybe from 2007 but that code still works JohnOne 1 TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
newniman Posted May 18, 2015 Share Posted May 18, 2015 (edited) ...[]...MsgBox(0, "Info", "Cell selected: " & _GUICtrlListView_GetItemText($hListview, $aHit[0], $aHit[1]) & @CR, 0, $hGUI)...[]... The code listed by johnmcloud does not appear to work.If I run the complete code, when "SubItem2" is selected and the "Value?" button is pressed the message box above reports:"Cell selected SubItem 2" (see png attached):I would have expected:"Cell selected Item12, SubItem 2"To have been reported.I'm attempting to use similar code to allow a user to identify a zoom step on a camera (from among 128 zoom steps) and then select an aperture value (from amongst 8 available values).Any code / comment to progress the challenge would be appreciated.(Please also note the error in johnmccloud source above:$$hListview --> should be $hListview ) Edited May 18, 2015 by newniman Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 18, 2015 Moderators Share Posted May 18, 2015 newniman,The code works perfectly - but it returns the text of the selected cell. If you want to get the location of the selected cell then use this:MsgBox(0, "Info", "Cell selected: Row" & $aHit[0] & " - Col: " & $aHit[1], 0, $hGUI)M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
newniman Posted May 18, 2015 Share Posted May 18, 2015 Splendid Melba23,i'm sure you'll not believe i've been struggling with this for the last 2 hours .Silly confusion on my behalf. Easy when you know how - i'll not forget that one Thanks a lot. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 18, 2015 Moderators Share Posted May 18, 2015 newniman,Glad I could help.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
newniman Posted May 18, 2015 Share Posted May 18, 2015 (edited) Any chance of a code edit hint to disable items in the first column being selected (Zoom Step in my attached png) ? Edited May 18, 2015 by newniman Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 18, 2015 Moderators Share Posted May 18, 2015 newniman,Something like this inside the $NM_CUSTOMDRAW handler seems to work:Switch $iSubItem Case $aHit[1] ; Marked column If $aHit[1] > 0 Then ; Only act on column 1+ <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< DllStructSetData($tNMLVCUSTOMDRAW, "ClrText", 0xFFFFFF) ; Forecolor white DllStructSetData($tNMLVCUSTOMDRAW, "clrTextBk", 0xCC6600) ; Backcolor dark blue, BGR Else ContinueCase EndIf Case Else ; Other columns DllStructSetData($tNMLVCUSTOMDRAW, "ClrText", 0x000000) ; Forecolor black DllStructSetData($tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF) ; Backcolor white EndSwitchNow you only highlight column 1+. But beware - you still get the selected items returned so you will need to add some code to prevent these selections being actioned:Case $iButton If $aHit[1] > 0 Then ; Do not action column 0 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< MsgBox(0, "Info", "Cell selected: Row" & $aHit[0] & " - Col: " & $aHit[1], 0, $hGUI) EndIfM23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
newniman Posted May 19, 2015 Share Posted May 19, 2015 Melba23, I haven't had a chance to try your suggestion yet - instead i've got stuck again at baby first steps (i'm old too )I created the listview items from a text file (attached) and, as far as I understand, otherwise maintained the same logic to johnmcloud's original:expandcollapse popup#include <file.au3> #include <string.au3> #include <array.au3> #include <Constants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <TabConstants.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <ListviewConstants.au3> #include <GuiListView.au3> #include <GUIListBox.au3> ;Opt("MustDeclareVars", 1) Global $hGUI, $hListview, $aHit[2] = [-1, -1] ; $aHit contains row & col of marked cell $hGUI = GUICreate("Mark Cell in Listview", 1040, 590) Local $iListview = GUICtrlCreateListView("Zoom Step|F3.4|F4.0|F4.5|F5.0|F5.6|F6.3|F7.1|F8.0", 24, 100, 472, 300, $LVS_REPORT, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") Local $PIPEFILE = "C:\edit-zoom_step_av_value.csv" Local $aRetArray _FileReadToArray($PIPEFILE, $aRetArray, $FRTA_NOCOUNT, "|") Local $iRows = UBound($aRetArray, $UBOUND_ROWS) ; Total number of rows. For $x = 0 to $iRows-1 GUICtrlCreateListViewItem($aRetArray[$x][0] & "|" & $aRetArray[$x][1] & "|" & $aRetArray[$x][2] & "|" & $aRetArray[$x][3] & "|" & $aRetArray[$x][4] & "|" _ & $aRetArray[$x][5] & "|" & $aRetArray[$x][6] & "|" & $aRetArray[$x][7] & "|" & $aRetArray[$x][8] , $iListview) Next $hListview = GUICtrlGetHandle($iListview) Local $iButton = GUICtrlCreateButton("Value?", 150, 430, 70, 20) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY"); good tutorial @ https://www.autoitscript.com/wiki/Tutorial_GUIRegisterMsg While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $iButton MsgBox(0, "Info", "Cell selected: " & _GUICtrlListView_GetItemText($hListview, $aHit[0], $aHit[1]) & @CR, 0, $hGUI) ;MsgBox(0, "Info", "zoom_step selected: " & $aHit[0] & " --> Aperture column selected: " & $aHit[1], 0, $hGUI) EndSwitch WEnd Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam ; https://www.autoitscript.com/forum/topic/72304-forceref/ --> It is used by au3check to tell it not to report on "variable not used" when using the parameter "-w 5" (i think) Local $tNMHDR, $hWndFrom, $iCode $tNMHDR = DllStructCreate($tagNMHDR, $lParam) ; https://www.autoitscript.com/autoit3/docs/functions/DllStructCreate.htm --> Creates a C/C++ style structure to be used in DllCall. $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListview Switch $iCode Case $LVN_ITEMCHANGED Local $tNMLISTVIEW, $iItem, $aInfo $tNMLISTVIEW = DllStructCreate($tagNMLISTVIEW, $lParam) $iItem = DllStructGetData($tNMLISTVIEW, "Item") _GUICtrlListView_SetItemSelected($hListview, $iItem, False) Local $aInfo = GUIGetCursorInfo($hGUI) If $aInfo[2] Then $aInfo = _GUICtrlListView_SubItemHitTest($hListview, $aInfo[0] - 2, $aInfo[1] - 2) ; Upper left = ( 2, 2 ) If $aInfo[0] > -1 And $aInfo[1] > -1 And $aInfo[0] = $iItem Then If $aHit[0] > -1 Then _GUICtrlListView_RedrawItems($hListview, $aHit[0], $aHit[0]) If $aHit[0] <> $aInfo[0] Or $aHit[1] <> $aInfo[1] Then $aHit[0] = $aInfo[0] ; Row $aHit[1] = $aInfo[1] ; Col Else $aHit[0] = -1 ; Row $aHit[1] = -1 ; Col EndIf _GUICtrlListView_RedrawItems($hListview, $iItem, $iItem) EndIf EndIf Case $NM_CUSTOMDRAW Local $tNMLVCUSTOMDRAW = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) Local $dwDrawStage = DllStructGetData($tNMLVCUSTOMDRAW, "dwDrawStage") Switch $dwDrawStage ; Holds a value that specifies the drawing stage Case $CDDS_PREPAINT ; Before the paint cycle begins Return $CDRF_NOTIFYITEMDRAW ; Notify the parent window of any ITEM-related drawing operations Case $CDDS_ITEMPREPAINT ; Before painting an item Return $CDRF_NOTIFYSUBITEMDRAW ; Notify the parent window of any SUBITEM-related drawing operations Case BitOR($CDDS_ITEMPREPAINT, $CDDS_SUBITEM) ; Before painting a subitem Local $dwItemSpec = DllStructGetData($tNMLVCUSTOMDRAW, "dwItemSpec") ; Item index Local $iSubItem = DllStructGetData($tNMLVCUSTOMDRAW, "iSubItem") ; Subitem index Local $uItemState = DllStructGetData($tNMLVCUSTOMDRAW, "uItemState") ; Item state If $dwItemSpec = $aHit[0] Then ; Marked row Switch $iSubItem Case $aHit[1] ; Marked column DllStructSetData($tNMLVCUSTOMDRAW, "ClrText", 0xFFFFFF) ; Forecolor white DllStructSetData($tNMLVCUSTOMDRAW, "clrTextBk", 0xCC6600) ; Backcolor dark blue, BGR Case Else ; Other columns DllStructSetData($tNMLVCUSTOMDRAW, "ClrText", 0x000000) ; Forecolor black DllStructSetData($tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF) ; Backcolor white EndSwitch Else ; Other rows DllStructSetData($tNMLVCUSTOMDRAW, "ClrText", 0x000000) DllStructSetData($tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF) EndIf Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFYSo that may not be pretty, but I can't now select items from the listview and don't understand why not edit-zoom_step_av_value.csv Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 19, 2015 Moderators Share Posted May 19, 2015 newniman,The problem was that you had not correctly set the position of the ListView within the GUI - see line #55 of this amended script:expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <File.au3> #include <GuiListView.au3> Global $hGUI, $hListview, $aHit[2] = [-1, -1] ; $aHit contains row & col of marked cell Local $PIPEFILE = "edit-zoom_step_av_value.csv" Local $aRetArray _FileReadToArray($PIPEFILE, $aRetArray, $FRTA_NOCOUNT);, "|") ; As the delimiters are already "!" why bother to split the lines? <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $hGUI = GUICreate("Mark Cell in Listview", 1040, 590) Local $cListview = GUICtrlCreateListView("Zoom Step|F3.4|F4.0|F4.5|F5.0|F5.6|F6.3|F7.1|F8.0", 24, 100, 472, 300, $LVS_REPORT, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) $hListview = GUICtrlGetHandle($cListview) GUICtrlSetFont($cListview, 8, 800, 0, "MS Sans Serif") For $x = 0 To UBound($aRetArray, $UBOUND_ROWS) - 1 ; As the "|" are already in place, this is much easier to write! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< GUICtrlCreateListViewItem($aRetArray[$x], $cListview) Next Local $cButton = GUICtrlCreateButton("Value?", 150, 430, 70, 20) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY"); good tutorial @ https://www.autoitscript.com/wiki/Tutorial_GUIRegisterMsg While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton MsgBox(0, "Info", "Cell selected: " & _GUICtrlListView_GetItemText($hListview, $aHit[0], $aHit[1]) & @CR, 0, $hGUI) ;MsgBox(0, "Info", "zoom_step selected: " & $aHit[0] & " --> Aperture column selected: " & $aHit[1], 0, $hGUI) EndSwitch WEnd Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam ; Used by au3check to tell it not to report on "variable not used" when using the parameter "-w 5" - Correct <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Local $tNMHDR, $hWndFrom, $iCode $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListview Switch $iCode Case $LVN_ITEMCHANGED Local $tNMLISTVIEW, $iItem, $aInfo $tNMLISTVIEW = DllStructCreate($tagNMLISTVIEW, $lParam) $iItem = DllStructGetData($tNMLISTVIEW, "Item") _GUICtrlListView_SetItemSelected($hListview, $iItem, False) Local $aInfo = GUIGetCursorInfo($hGUI) If $aInfo[2] Then $aInfo = _GUICtrlListView_SubItemHitTest($hListview, $aInfo[0] - 24, $aInfo[1] - 100) ; Upper left position of ListView within GUI - so must match actual position If $aInfo[0] > -1 And $aInfo[1] > -1 And $aInfo[0] = $iItem Then If $aHit[0] > -1 Then _GUICtrlListView_RedrawItems($hListview, $aHit[0], $aHit[0]) If $aHit[0] <> $aInfo[0] Or $aHit[1] <> $aInfo[1] Then $aHit[0] = $aInfo[0] ; Row $aHit[1] = $aInfo[1] ; Col Else $aHit[0] = -1 ; Row $aHit[1] = -1 ; Col EndIf _GUICtrlListView_RedrawItems($hListview, $iItem, $iItem) EndIf EndIf Case $NM_CUSTOMDRAW Local $tNMLVCUSTOMDRAW = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) Local $dwDrawStage = DllStructGetData($tNMLVCUSTOMDRAW, "dwDrawStage") Switch $dwDrawStage ; Holds a value that specifies the drawing stage Case $CDDS_PREPAINT ; Before the paint cycle begins Return $CDRF_NOTIFYITEMDRAW ; Notify the parent window of any ITEM-related drawing operations Case $CDDS_ITEMPREPAINT ; Before painting an item Return $CDRF_NOTIFYSUBITEMDRAW ; Notify the parent window of any SUBITEM-related drawing operations Case BitOR($CDDS_ITEMPREPAINT, $CDDS_SUBITEM) ; Before painting a subitem Local $dwItemSpec = DllStructGetData($tNMLVCUSTOMDRAW, "dwItemSpec") ; Item index Local $iSubItem = DllStructGetData($tNMLVCUSTOMDRAW, "iSubItem") ; Subitem index Local $uItemState = DllStructGetData($tNMLVCUSTOMDRAW, "uItemState") ; Item state If $dwItemSpec = $aHit[0] Then ; Marked row Switch $iSubItem Case $aHit[1] ; Marked column DllStructSetData($tNMLVCUSTOMDRAW, "ClrText", 0xFFFFFF) ; Forecolor white DllStructSetData($tNMLVCUSTOMDRAW, "clrTextBk", 0xCC6600) ; Backcolor dark blue, BGR Case Else ; Other columns DllStructSetData($tNMLVCUSTOMDRAW, "ClrText", 0x000000) ; Forecolor black DllStructSetData($tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF) ; Backcolor white EndSwitch Else ; Other rows DllStructSetData($tNMLVCUSTOMDRAW, "ClrText", 0x000000) DllStructSetData($tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF) EndIf Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFYI also removed most of the include files (which were not all necessary) and cleaned up the _FileReadToArray code which makes creating the ListView items much easier.M23 newniman, pixelsearch, robertocm and 1 other 3 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 Link to comment Share on other sites More sharing options...
newniman Posted May 19, 2015 Share Posted May 19, 2015 Thanks a million Melba23...this is more than i'd hoped for at this stage. Probably need to grow a few more synapses before I fully understand but you have given a great head start. I may not be great at artistic design either, but it's functional ok. Here's a screenshot (i'll disable 1st column & do the other stuff you suggest later): Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 19, 2015 Moderators Share Posted May 19, 2015 newniman,Delighted I could help. Do not hesitate to ask for further explanations if your synapses refuse to grow - or if you need any more help with the script overall (but please do that in another thread).M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
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