Hello,
I am looking for a way to determine if a scrollbar exists on a listView control. I tried this:
This did not work. I would think that if there is no scroll bar, then the "revtal" variable would be zero--but it is 1. Then I thought that maybe there is some variable in the scrollinfo structure that could be used. However, I found none. The nMax and nMin both have strange values although there is no scrollbar?!?
The next attempt was to see how long the rect of one of the listview's item is:
I thought if the rect's length is as wide as the controls's width, then that might signal no scrollbar. Oddly enough, it appears that when I combine both attempts then I see something that might work. The scrollinfo.nMax is just a pixel shorter than the rc.nright. So maybe:
Does this make sense? Can somebody think of a better way of doing it?
I have thought of looping through all the columns to total the columns' widths and then comparing that do the size of the control; however, that seems like a guess and check idea that ignores any scrollbar data. Any comments or insight would be greatly appreciated?
I am looking for a way to determine if a scrollbar exists on a listView control. I tried this:
Code:
LOCAL si AS SCROLLINFO LOCAL retval, w, h AS LONG si.cbSize = SIZEOF(si) si.fMask = %SIF_ALL retval= getscrollinfo(GetDlgItem(hdlg, %ID_ListView), %SB_HORZ, si)
The next attempt was to see how long the rect of one of the listview's item is:
Code:
local rc as rect, hlv as long CONTROL HANDLE CBHNDL, %ID_LIstView TO hLV rc.nleft = %LVIR_BOUNDS SendMessage(hlv, %LVM_GETITEMRECT, 1, VARPTR(rc))
Code:
IF scrollinfo.nMax + 1 = (rect.NRight - Rect.NLeft) then 'there is no scrollbar else 'there is a scrollbar end if
I have thought of looping through all the columns to total the columns' widths and then comparing that do the size of the control; however, that seems like a guess and check idea that ignores any scrollbar data. Any comments or insight would be greatly appreciated?
Comment