1. line size of the listview

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

new topic     » topic index » view message » categorize

2. Re: line size of the listview

size=getFontSize ( ListViewInQuestion)

Don Cole

new topic     » goto parent     » topic index » view message » categorize

3. Re: line size of the listview

dcole said...

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?

new topic     » goto parent     » topic index » view message » categorize

4. Re: line size of the listview

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.

new topic     » goto parent     » topic index » view message » categorize

5. Re: line size of the listview

LarryMiller said...

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?

new topic     » goto parent     » topic index » view message » categorize

6. Re: line size of the listview

LarryMiller said...

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.

new topic     » goto parent     » topic index » view message » categorize

7. Re: line size of the listview

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 
new topic     » goto parent     » topic index » view message » categorize

8. Re: line size of the listview

m_sabal said...
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?

new topic     » goto parent     » topic index » view message » categorize

9. Re: line size of the listview

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 
sergelli said...

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?

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 
new topic     » goto parent     » topic index » view message » categorize

10. Re: line size of the listview - Resolved

Thank you, Derek. Everything worked perfectly.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu