determine visible VScrollBar in ListView

V

Vladimir.Sakharuk

I am trying to find a way how to determine is scrollBar visible in C#.
The target is to subtract its width from calculation of the visible
area in ListView. I have find where I can get the standard size of the
scrollbars but could not find how to check is it enabled on the form.

Thanks
 
S

Sergey Bogdanov

When the vertical scrollbar is visible then its window has WS_VSCROLL
style (or WS_HSCROLL for vertical horizontal scrollbar):

ctrl.Capture = true;
IntPtr hWnd = GetCapture();
ctrl.Capture = false;

bool isVisible = GetWindowLong(hWnd, GWL_STYLE) & WS_VSCROLL) != 0;

....

[DllImport("coredll")]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);

private const int WS_VSCROLL = 0x200000;
private const int GWL_STYLE = (-16);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top