第1个回答 2013-11-01
可以参考如下的代码:
private const int WM_VSCROLL = 0x115;
// Scroll Bar Constants
private const int SB_HORZ = 0;
private const int SB_VERT = 1;
private const int SB_CTL = 2;
private const int SB_BOTH = 3;
// Scroll Bar Commands
private const int SB_LINEUP = 0;
private const int SB_LINELEFT = 0;
private const int SB_LINEDOWN = 1;
private const int SB_LINERIGHT = 1;
private const int SB_PAGEUP = 2;
private const int SB_PAGELEFT = 2;
private const int SB_PAGEDOWN = 3;
private const int SB_PAGERIGHT = 3;
private const int SB_THUMBPOSITION = 4;
private const int SB_THUMBTRACK = 5;
private const int SB_TOP = 6;
private const int SB_LEFT = 6;
private const int SB_BOTTOM = 7;
private const int SB_RIGHT = 7;
private const int SB_ENDSCROLL = 8;
private const int WM_PAINT = 0x000F;
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern bool ScrollWindow(IntPtr hWnd, int XAmount,int YAmount,ref Rectangle lpRect,ref Rectangle lpClipRect);
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern int SetScrollPos(IntPtr hwnd ,int nBar ,int nPos ,bool bRedraw );
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern int SetScrollPos(int nBar,int nPos,bool bRedraw );
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern bool UpdateWindow(IntPtr hWnd);
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hwnd ,int wMsg ,int wParam ,int lParam );
private void SelfSrcoll(IntPtr handle)
{
SendMessage(handle, WM_VSCROLL, SB_LINEDOWN, 0);
//UpdateWindow(handle);
}
private void button3_Click(object sender, System.EventArgs e)
{
SelfSrcoll(this.richTextBox1.Handle);
}