determine visible VScrollBar in ListView

  • Thread starter Thread starter Vladimir.Sakharuk
  • Start date Start date
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
 
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);
 
Back
Top