1. line size of the listview
- Posted by SergioGelli May 12, 2010
- 1804 views
Hello everybody, I need a function that returns the height of a row of a listview created with win32Lib Please, could someone post an example? Thanks in advance
Sergio Gelli
2. Re: line size of the listview
- Posted by dcole May 12, 2010
- 1709 views
size=getFontSize ( ListViewInQuestion)
Don Cole
3. Re: line size of the listview
- Posted by SergioGelli May 13, 2010
- 1680 views
size=getFontSize ( ListViewInQuestion) Don Cole
ok, size[2]+1 gives the height of each line, but I'm confused, check this out:
When I turn on the machine and the road program for the first time, the getFontSize() return size[2] = 16 and the real heigth of line is 17 In another machine, getFontSize() return size[2]=20, but the real line size = 21 O.K...Just increase +1 solves the problem.
But if the program uses setFont() in any future proceedings, the return is not the same.
In my system, getFontSize return size[2] = 13 But, the real heigth is 17
And the code below, still leaves me a bit confused
- euCode
setFont( ListViewInQuestion,"MS Sans Serif",30,Normal)
size=getFontSize ( ListViewInQuestion )
In this case getFontSize() return size[2] = 30, but on screen, the line height remains the same: heith=17.
Maybe I should make the code with some instructions to stabilize the return of function gerFontSize(). But I do not know how. Any suggestions?
4. Re: line size of the listview
- Posted by LarryMiller May 13, 2010
- 1721 views
The height of the text in a Listview is not a reliable measurement of the item height. The correct way to do this is to use the LVM_GETITEMRECT message.
http://msdn.microsoft.com/en-us/library/bb761049%28v=VS.85%29.aspx
I haven't used Win32lib for a long time and don't remember the proper usage in Win32lib.
I can find the necessary constants if Win32lib does not define them.
5. Re: line size of the listview
- Posted by SergioGelli May 13, 2010
- 1706 views
The correct way to do this is to use the LVM_GETITEMRECT message. http://msdn.microsoft.com/en-us/library/bb761049%28v=VS.85%29.aspx
Crying...I do not know to handle it. And now? Is there a doc, something to learn about it?
6. Re: line size of the listview
- Posted by SergioGelli May 14, 2010
- 1665 views
The height of the text in a Listview is not a reliable measurement of the item height. The correct way to do this is to use the LVM_GETITEMRECT message.
The win32lib.ew LVM_GETITEMRECT mentions in the archives. Doc and html, but no further explanation. I'm not getting out of this problem.
Please could you help by giving an example of using the LVM_GETITEMRECT message.
7. Re: line size of the listview
- Posted by m_sabal May 14, 2010
- 1670 views
This is untested, and it's been a while since I've played with the internals of Win32Lib, but this should at least get you started.
atom rectptr atom top,bottom,height rectptr = allocate(16) VOID = sendMessage(id,LVM_GETITEMRECT,rectptr,0) top = peek4u(rectptr+4) bottom = peek4u(rectptr+12) height = bottom-top
8. Re: line size of the listview
- Posted by sergelli May 14, 2010
- 1601 views
atom rectptr atom top,bottom,height rectptr = allocate(16) VOID = sendMessage(id,LVM_GETITEMRECT,rectptr,0) top = peek4u(rectptr+4) bottom = peek4u(rectptr+12) height = bottom-top
this code works fine with a valid id ctrl.
But what is the id of a row of ListView?
The manuals win32lib say the id is the return of a addLvItem (), but this is not true.
How do I find the id of a row of the ListView, to use in your code above?
9. Re: line size of the listview
- Posted by DerekParnell (admin) May 14, 2010
- 1624 views
Here a tested routine ...
constant vValidLVRect = {LVIR_BOUNDS, LVIR_ICON, LVIR_LABEL, LVIR_SELECTBOUNDS} global function LVGetItemSize(integer id, integer pItem, integer pWhich) integer lRect integer lTop integer lBottom integer lLeft integer lRight atom lResult -- Reserve some RAM for the bounding rectangle values. lRect = w32acquire_mem( 0, SIZEOF_RECT ) -- Indicate which rectangle is required to be fetched. if not find(pWhich, vValidLVRect) then pWhich = LVIR_BOUNDS end if w32store(lRect, rectLeft, pWhich) -- Tell Windows to fetch the data for the specific item requested. lResult = sendMessage(id, LVM_GETITEMRECT, pItem - 1, lRect) if lResult = 0 then -- Failed. w32release_mem(lRect) return {} end if -- Get box data lTop = w32fetch(lRect, rectTop) lBottom = w32fetch(lRect, rectBottom) lLeft = w32fetch(lRect, rectLeft) lRight = w32fetch(lRect, rectRight) -- Return RAM to opsys w32release_mem(lRect) -- Return height, width, and box points return {lBottom - lTop, lRight - lLeft, lLeft, lRight, lTop, lBottom} end function
You use it like this ...
sequence itemid sequence BoxData -- get id of currently selected item. itemid = getIndex(TheListView) BoxData = LVGetItemSize(TheListView, itemid[1], 0) if length(BoxData) != 0 then -- Height is in BoxData[1] end if
10. Re: line size of the listview - Resolved
- Posted by sergelli May 15, 2010
- 1560 views
Thank you, Derek. Everything worked perfectly.