• LVM_GETITEMPOSITION unexpected result

    From R.Wieser@21:1/5 to All on Thu Dec 12 15:08:02 2024
    Hello all,

    In a listview in basic LVS_ICON mode (no grouping) I'm trying the get the location of an item. For that I'm using LVM_GETITEMPOSITION.

    The problem is that it gives a way to large X position for all items (iow,
    its a constant value of "too big").

    Also, the first item gives a LVM_GETITEMPOSITION result of 0x00000015 0x00000002. The same item gives a LVM_GETITEMRECT result of 0x0000000D 0x00000000 0x0000003D 0x00000035.

    Notice how the RECT X and Y results are, quite unexpected to me, *smaller*
    than the POSITONs X and Y results.

    Does anyone knows whats going on ? What is LVM_GETITEMPOSITION actually returning ?

    Regards,
    Rudy Wieser

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From JJ@21:1/5 to R.Wieser on Fri Dec 13 15:42:07 2024
    On Thu, 12 Dec 2024 15:08:02 +0100, R.Wieser wrote:
    Hello all,

    In a listview in basic LVS_ICON mode (no grouping) I'm trying the get the location of an item. For that I'm using LVM_GETITEMPOSITION.

    The problem is that it gives a way to large X position for all items (iow, its a constant value of "too big").

    Also, the first item gives a LVM_GETITEMPOSITION result of 0x00000015 0x00000002. The same item gives a LVM_GETITEMRECT result of 0x0000000D 0x00000000 0x0000003D 0x00000035.

    Notice how the RECT X and Y results are, quite unexpected to me, *smaller* than the POSITONs X and Y results.

    Does anyone knows whats going on ? What is LVM_GETITEMPOSITION actually returning ?

    Regards,
    Rudy Wieser

    Have you checked it against the item's icon RECT?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From R.Wieser@21:1/5 to All on Sat Dec 14 09:09:14 2024
    JJ,

    Have you checked it against the item's icon RECT?

    I thought about that being a possible reason, and just checking it it looks like you hit the nail on the head. :-)

    Its just that I didn't expect a LVM_GET*ITEM*POSITION call to return the position of something (the icon) inside of it. :-|

    Any idea how I can get the top-left of the item itself ? (I'm trying to
    draw a more visible focus indicator).

    Regards,
    Rudy Wieser

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From JJ@21:1/5 to R.Wieser on Sun Dec 15 15:39:39 2024
    On Sat, 14 Dec 2024 09:09:14 +0100, R.Wieser wrote:
    JJ,

    Have you checked it against the item's icon RECT?

    I thought about that being a possible reason, and just checking it it looks like you hit the nail on the head. :-)

    Its just that I didn't expect a LVM_GET*ITEM*POSITION call to return the position of something (the icon) inside of it. :-|

    Any idea how I can get the top-left of the item itself ? (I'm trying to
    draw a more visible focus indicator).

    Regards,
    Rudy Wieser

    Just give LVM_GETITEMRECT which information you want. Or did you overlooked
    it in the documentation?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From R.Wieser@21:1/5 to All on Sun Dec 15 10:57:21 2024
    JJ,

    Any idea how I can get the top-left of the item itself ? (I'm
    trying to draw a more visible focus indicator).
    ...
    Just give LVM_GETITEMRECT which information you want. Or did you
    overlooked it in the documentation?

    Did you overlook that I also mentioned that one in my inital message (and included results of both), and that its documentation says it returns the *boundary* of the item (which turns out to be the smallest box which
    encompass all in it) ? :-p

    Yeah, I tested (and drawn) both.

    Regards,
    Rudy Wieser

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From JJ@21:1/5 to R.Wieser on Mon Dec 16 12:14:47 2024
    On Sun, 15 Dec 2024 10:57:21 +0100, R.Wieser wrote:
    JJ,

    Any idea how I can get the top-left of the item itself ? (I'm
    trying to draw a more visible focus indicator).
    ....
    Just give LVM_GETITEMRECT which information you want. Or did you
    overlooked it in the documentation?

    Did you overlook that I also mentioned that one in my inital message (and included results of both), and that its documentation says it returns the *boundary* of the item (which turns out to be the smallest box which encompass all in it) ? :-p

    Yeah, I tested (and drawn) both.

    Regards,
    Rudy Wieser

    I'm not referring to the result.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From R.Wieser@21:1/5 to All on Mon Dec 16 08:37:44 2024
    JJ,

    Just give LVM_GETITEMRECT which information you want. Or did you
    overlooked it in the documentation?

    Did you overlook that I also mentioned that one in my inital message (and
    included results of both), and that its documentation says it returns the
    *boundary* of the item (which turns out to be the smallest box which
    encompass all in it) ? :-p

    Yeah, I tested (and drawn) both.
    ...
    I'm not referring to the result.

    Than you've lost me. What /are/ you referring to ?


    For your information, the below is the code I am using :

    -- Inside the CDRF_NOTIFYITEMDRAW notification

    lea esi,[@@rRect]
    call RtlZeroMemory,esi,size RECT ;Implicite LVIR_BOUNDS request.
    call SendMessageA,[ebx].NMH_hWndFrom,LVM_GETITEMRECT \
    ,[ebx].NMCD_lItemSpec,esi

    call Rectangle,[ebx].NMCD_hDC \
    ,[esi].R_lLeft,[esi].R_lTop \
    ,[esi].R_lRight,[esi].R_lBottom

    Using the above I get rectangles draw of all different sizes, depending on
    the ammount/size of the text in the item. What I expect (and need) is
    a series of same-sized rectangles that have no gaps between them.

    If you see anything wrong with the above code please do tell.

    Remark: To make damn sure I just tested the different LVIR_* possibilities,
    and see no difference between LVIR_BOUNDS and LVIR_BOUNDSSELECT. :-|

    Regards,
    Rudy Wieser

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Udo Steinbach@21:1/5 to All on Wed Dec 18 14:08:25 2024
    Without any knowledge I would think that the 3 words „in view coordinates“ make the difference, <=> „in the current view“. And „The position of list-
    view items is specified in view coordinates, which are client coordinates offset by the scroll position.“

    --
    Fahrradverkehr in Deutschland: http://radwege.udoline.de/
    GPG: A245 F153 0636 6E34 E2F3 E1EB 817A B14D 3E7E 482E

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From R.Wieser@21:1/5 to All on Wed Dec 18 15:25:59 2024
    Udo,

    Without any knowledge I would think that the 3 words "in view coordinates" make the difference, <=> "in the current view". And "The position of
    list-
    view items is specified in view coordinates, which are client coordinates offset by the scroll position."

    When I did draw the rectangle returned by LVM_GETITEMRECT and a cross where LVM_GETITEMPOSITION pointed to both stayed rock-steady on their respective items - regardless of a horizontal/vertical scroll.

    Which is, I must say, something I expected (I didn't think that
    non-releative to the client rectangle would be of much use for drawing purposes).

    The only problem is that neither indicates the actual top-left of its item
    (a shown by the "selected item" rectangle as displayed by the LVS_EX_BORDERSELECT setting). :-(


    To me it looks like that I can only get that "selected item" top-left
    location by taking the result of LVM_GETITEMPOSITION, apply the scrolled
    origin from LVM_GETVIEWRECT, divide by the result of LVM_GETITEMSPACING,
    floor the results and re-multiply by it again.

    ... which feels rather hackish to me.

    I still have to test that though.

    Its not the first time I try to do something seemingly very basic/simple,
    only to find out no method for it is exposed (even though the "selected" rectangle shows its already done internally) - but that the result I /can/
    get (the top/left of the icon) is possible in two different ways. Go figure. :-\

    Regards,
    Rudy Wieser

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)