Is there a way to find out if the vertical ScrollBar is visible in an ObjectListView please?
Old question, but here is the answer in case somebody else needs it:
[DllImport("user32.dll", EntryPoint = "GetWindowLong", CharSet = CharSet.Auto)] public static extern IntPtr GetWindowLong32(IntPtr hWnd, int nIndex);
[DllImport("user32.dll", EntryPoint = "GetWindowLongPtr", CharSet = CharSet.Auto)] public static extern IntPtr GetWindowLongPtr64(IntPtr hWnd, int nIndex);
private bool HasHorizontalScrollBar(ListView lv) { const int GWL_STYLE = -16; const int WS_HSCROLL = 0x00100000;
return (GetWindowLong(lv.Handle, GWL_STYLE) & WS_HSCROLL) != 0;
}
private bool HasVerticalScrollBar(ListView lv) { const int GWL_STYLE = -16; const int WS_VSCROLL = 0x00200000;
return (GetWindowLong(lv.Handle, GWL_STYLE) & WS_VSCROLL) != 0;
private int GetWindowLong(IntPtr hWnd, int nIndex) { if (IntPtr.Size == 4) return (int)GetWindowLong32(hWnd, nIndex); else return (int)(long)GetWindowLongPtr64(hWnd, nIndex); }
Many thanks, Johnny J, works a treat!
Log in to post a comment.
Is there a way to find out if the vertical ScrollBar is visible in an ObjectListView please?
Old question, but here is the answer in case somebody else needs it:
[DllImport("user32.dll", EntryPoint = "GetWindowLong", CharSet = CharSet.Auto)]
public static extern IntPtr GetWindowLong32(IntPtr hWnd, int nIndex);
[DllImport("user32.dll", EntryPoint = "GetWindowLongPtr", CharSet = CharSet.Auto)]
public static extern IntPtr GetWindowLongPtr64(IntPtr hWnd, int nIndex);
private bool HasHorizontalScrollBar(ListView lv)
{
const int GWL_STYLE = -16;
const int WS_HSCROLL = 0x00100000;
}
private bool HasVerticalScrollBar(ListView lv)
{
const int GWL_STYLE = -16;
const int WS_VSCROLL = 0x00200000;
}
private int GetWindowLong(IntPtr hWnd, int nIndex)
{
if (IntPtr.Size == 4)
return (int)GetWindowLong32(hWnd, nIndex);
else
return (int)(long)GetWindowLongPtr64(hWnd, nIndex);
}
Many thanks, Johnny J, works a treat!