哪位兼通VC和VB的高手帮我把这断VB代码改写成VB的代码(包括API声明),不胜感激!
privateintmin,max;privateintpos=0;privateintendPos=0;privateconstintSB_HORZ=0x0;priva...
private int min, max;
private int pos = 0;
private int endPos = 0;
private const int SB_HORZ = 0x0;
private const int SB_VERT = 0x1;
private const int WM_HSCROLL = 0x114;
private const int WM_VSCROLL = 0x115;
private const int SB_THUMBPOSITION = 4;
[DllImport("user32.dll")]
private static extern int SetScrollPos(IntPtr hwnd, int nBar, int nPos, bool bRedraw);
[DllImport("user32.dll")]
private static extern int GetScrollPos(IntPtr hwnd, int nBar);
[DllImport("user32.dll")]
private static extern bool PostMessage(IntPtr hWnd, int nBar, int wParam, int lParam);
[DllImport("user32", CharSet = CharSet.Auto)]
private static extern bool GetScrollRange(IntPtr hWnd, int nBar, out int lpMinPos, out int lpMaxPos);
private void timer1_Tick(object sender, EventArgs e)
{
pos = GetScrollPos(testRichTextBox1.Handle, SB_VERT);//加上这句是为了如果用户手动拖拽滚动条,可以保证滚动条继续从拖拽的位置走
pos++;
//如果已经到底,那么停止Timer
if (pos > endPos)
{
this.timer1.Enabled = false;
return;
}
SetScrollPos(testRichTextBox1.Handle, SB_VERT, pos, true);
PostMessage(testRichTextBox1.Handle, WM_VSCROLL, SB_THUMBPOSITION + 0x10000 * pos, 0);
}
//点击Button,启动Timer
private void button_Click(object sender, EventArgs e)
{
//得到滚动条的最大最小值
GetScrollRange(testRichTextBox1.Handle, SB_VERT, out min, out max);
//得到滚动条到最底下的实际位置
endPos = max - testRichTextBox1.ClientRectangle.Height;
this.timer1.Enabled = true;
}
我想用VB实现RichTextBox中的文本循环滚动,也就是滚动条到底后重新从第一行开始滚动。中间如果用户手动拖拽滚动条,可以保证滚动条继续从拖拽的位置走 展开
private int pos = 0;
private int endPos = 0;
private const int SB_HORZ = 0x0;
private const int SB_VERT = 0x1;
private const int WM_HSCROLL = 0x114;
private const int WM_VSCROLL = 0x115;
private const int SB_THUMBPOSITION = 4;
[DllImport("user32.dll")]
private static extern int SetScrollPos(IntPtr hwnd, int nBar, int nPos, bool bRedraw);
[DllImport("user32.dll")]
private static extern int GetScrollPos(IntPtr hwnd, int nBar);
[DllImport("user32.dll")]
private static extern bool PostMessage(IntPtr hWnd, int nBar, int wParam, int lParam);
[DllImport("user32", CharSet = CharSet.Auto)]
private static extern bool GetScrollRange(IntPtr hWnd, int nBar, out int lpMinPos, out int lpMaxPos);
private void timer1_Tick(object sender, EventArgs e)
{
pos = GetScrollPos(testRichTextBox1.Handle, SB_VERT);//加上这句是为了如果用户手动拖拽滚动条,可以保证滚动条继续从拖拽的位置走
pos++;
//如果已经到底,那么停止Timer
if (pos > endPos)
{
this.timer1.Enabled = false;
return;
}
SetScrollPos(testRichTextBox1.Handle, SB_VERT, pos, true);
PostMessage(testRichTextBox1.Handle, WM_VSCROLL, SB_THUMBPOSITION + 0x10000 * pos, 0);
}
//点击Button,启动Timer
private void button_Click(object sender, EventArgs e)
{
//得到滚动条的最大最小值
GetScrollRange(testRichTextBox1.Handle, SB_VERT, out min, out max);
//得到滚动条到最底下的实际位置
endPos = max - testRichTextBox1.ClientRectangle.Height;
this.timer1.Enabled = true;
}
我想用VB实现RichTextBox中的文本循环滚动,也就是滚动条到底后重新从第一行开始滚动。中间如果用户手动拖拽滚动条,可以保证滚动条继续从拖拽的位置走 展开
展开全部
Private min, max As Integer
Private pos = 0
Private endPos = 0
private const SB_HORZ = 0
private const SB_VERT = 1
private const WM_HSCROLL = &H114
private const WM_VSCROLL = &H115
private const SB_THUMBPOSITION = 4
Private Declare Function SetScrollPos Lib "user32" Alias "SetScrollPos" (ByVal hwnd As Long, ByVal nBar As Long, ByVal nPos As Long, ByVal bRedraw As Long) As Long
Private Declare Function GetScrollPos Lib "user32" Alias "GetScrollPos" (ByVal hwnd As Long, ByVal nBar As Long) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function GetScrollRange Lib "user32" Alias "GetScrollRange" (ByVal hwnd As Long, ByVal nBar As Long, lpMinPos As Long, lpMaxPos As Long) As Long
Private Sub timer1_Timer()
pos = GetScrollPos(testRichTextBox1.Hwnd, SB_VERT)'加上这句是为了如果用户手动拖拽滚动条,可以保证滚动条继续从拖拽的位置走
pos++
'如果已经到底,那么停止Timer
if pos > endPos Then
timer1.Enabled = false
End If
SetScrollPos(testRichTextBox1.Hwnd, SB_VERT, pos, true)
PostMessage(testRichTextBox1.Hwnd, WM_VSCROLL, SB_THUMBPOSITION + &H10000 * pos, 0)
End Sub
'点击Button,启动Timer
Private Sub Command1_Click()
'得到滚动条的最大最小值
GetScrollRange(testRichTextBox1.Hwnd, SB_VERT, min, max)
'得到滚动条到最底下的实际位置
endPos = max - testRichTextBox1.ClientRectangle.Height '这一句不知道怎么改
timer1.Enabled = true
End Sub
Private pos = 0
Private endPos = 0
private const SB_HORZ = 0
private const SB_VERT = 1
private const WM_HSCROLL = &H114
private const WM_VSCROLL = &H115
private const SB_THUMBPOSITION = 4
Private Declare Function SetScrollPos Lib "user32" Alias "SetScrollPos" (ByVal hwnd As Long, ByVal nBar As Long, ByVal nPos As Long, ByVal bRedraw As Long) As Long
Private Declare Function GetScrollPos Lib "user32" Alias "GetScrollPos" (ByVal hwnd As Long, ByVal nBar As Long) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function GetScrollRange Lib "user32" Alias "GetScrollRange" (ByVal hwnd As Long, ByVal nBar As Long, lpMinPos As Long, lpMaxPos As Long) As Long
Private Sub timer1_Timer()
pos = GetScrollPos(testRichTextBox1.Hwnd, SB_VERT)'加上这句是为了如果用户手动拖拽滚动条,可以保证滚动条继续从拖拽的位置走
pos++
'如果已经到底,那么停止Timer
if pos > endPos Then
timer1.Enabled = false
End If
SetScrollPos(testRichTextBox1.Hwnd, SB_VERT, pos, true)
PostMessage(testRichTextBox1.Hwnd, WM_VSCROLL, SB_THUMBPOSITION + &H10000 * pos, 0)
End Sub
'点击Button,启动Timer
Private Sub Command1_Click()
'得到滚动条的最大最小值
GetScrollRange(testRichTextBox1.Hwnd, SB_VERT, min, max)
'得到滚动条到最底下的实际位置
endPos = max - testRichTextBox1.ClientRectangle.Height '这一句不知道怎么改
timer1.Enabled = true
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询