vb中的RichTextBox控件

vb中用RichTextBox控件怎样和Timer控件联系制作出
文档自动滚屏啊?
我找了点代码但只是点一个按钮向下挫一行,但不能自动向下移动!
代码:

Const EM_LINESCROLL = &HB6
Private Declare Function SendMessageBynum Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Private Sub Command20_Click()

SendMessageBynum RichTextBox1.hwnd, EM_LINESCROLL, 0, 1 ' 下卷一行

End Sub

Private Sub Timer1_Timer() '文字滚动
SendMessageLong RichTextBox.hwnd, EM_LINESCROLL, 0, 1
End Sub

能不能帮我将RichTextBox控件和Timer控件联系起来!!!
谢了!!!

第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);
}
相似回答