Re: line size of the listview
- Posted by DerekParnell (admin) May 14, 2010
- 1623 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
sergelli said...
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