You can also at any time - that is, you don't have to wait for a notification - get the mouse position with GetCursorPos(), convert to client coordinates with ScreenToClient (), then use the ListView_HitTest macro (or LVM_HITTEST message) to get the item and subitem (if any) at the cursor.
Your method in post #1 (LISTVIEW GET SELECT) of course does not work if the listview control is configured to support multiple selections OR if the cursor is not currently on the selected item. (depends on what you are doing).
Announcement
Collapse
No announcement yet.
ListView Notifications - Get Row/Col
Collapse
X
-
%NM_RCLICK, using same code.
And then of course if LOCAL lplvcd AS NMLVCUSTOMDRAW PTR,
then @lplvcd.nmcd.dwItemSpec is line and @lplvcd.iSubItem is column under %NM_CUSTOMDRAW
Leave a comment:
-
ListView Notifications - Get Row/Col
In the DDT world, I use this next line of code all the time, including within the dialog CallBack function, under various ListView notifications. It's easy enough to use.
Code:ListView Get Select hDlg, %IDC_ListView to iRow
Code:Local pLVDI As LV_DISPINFOW Ptr Local LVNT As NMItemActivate Ptr Local LVData As NM_ListView Local pNMLV As NMLISTVIEW Ptr Case %LVN_GetDispInfo pLVDI = Cb.LParam iRow = @pLVDI.item.iItem+1 iCol = @pLVDI.item.iSubItem+1 Case %NM_Click LVNT = Cb.LParam iRow = @LVNT.iItem+1 iCol = @LVNT.iSubItem+1 Case %NM_DblClk LVNT = Cb.LParam iRow = @LVNT.iItem+1 iCol = @LVNT.iSubItem+1 Case %LVN_ColumnClick Type Set LVData = Cb.NmHdr$(SizeOf(LVData)) iRow = LVData.iItem+1 iCol = LVData.iSubItem+1 Case %LVN_ItemChanged 'Mouse Click or Keyboard Arrow will cause this pNMLV = Cb.LParam iRow = @pNMLV.iItem+1 iCol = @pNMLV.iSubItem+1
Tags: None
Leave a comment: