I have a TListView (actually, a custom descendant) display in ViewStyle vsReport. One row is selected. I would like to get the screen coordinates of that row (or a cell within that row). Is there any way for me to do this?
(My goal is to display a small form over the list view giving the effect that it dropped down from the selected row).
I am using Delphi 2010 for this particular application.
For a list view in
vsReportstyle I believe the best approach is to use theLVM_GETITEMRECTandLVM_GETSUBITEMRECTmessages.The VCL does not wrap this functionality up for you but it should not be too difficult to work it out from the MSDN docs.
Whilst it is very simple to use the
TListItem.Positionproperty exposed by the VCL, as far as I can tell this does not help you obtain the row height or indeed the coordinates of sub items.Update
As NGLN very helpfully points out, the CommCtrl unit does expose
ListView_GetItemRectandListView_GetSubItemRectwhich are more convenient to use than the equivalent Windows messages above.