Removing ListView Scrollbars (II)

  • Thread starter Thread starter tom
  • Start date Start date
T

tom

BTW, don't press TAB to format your post and then hit
enter...like I did.

Like I said, I would like to replace a ListView's scroll
bars with buttons for easier use with a touch screen.

private static Int32 GWL_STYLE = (-16);
private static Int32 WS_VSCROLL = 0x00200000;
private static Int32 WS_HSCROLL = 0x00100000;
[DllImport("coredll")]
extern static IntPtr GetCapture();
[DllImport("coredll", CharSet=CharSet.Auto)]
internal static extern int SetWindowLong(IntPtr hWnd,
Int32 flag, int dwNewLong);
[DllImport("coredll", CharSet=CharSet.Auto)]
static internal extern Int32 GetWindowLong(IntPtr hWnd,
Int32 flag);

public static void removeListViewScrollBars
(System.Windows.Forms.ListView lV)
{
lV.Capture = true;
IntPtr iP = GetCapture();
Int32 GWret = GetWindowLong(iP,GWL_STYLE);
SetWindowLong(iP, GWL_STYLE, GWret & (~WS_VSCROLL));
lV.Capture = false;
}

I get 'real' return values from GetCapture and
GetWindowLong but...the scroll bar does not disappear.

I am calling after clearing, configuring and adding items
to the ListView, while it is disabled and invisible as
well as between BeginUpdate()/EndUpdate() calls.
 
Place the ListView on a Panel and make its size less then
on the size of the scroll bars.

HTH... Alex

P.S. You will have to send scroll messages to the ListView
to make it scroll...
 
Back
Top