哪位兼通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中的文本循环滚动,也就是滚动条到底后重新从第一行开始滚动。中间如果用户手动拖拽滚动条,可以保证滚动条继续从拖拽的位置走
展开
 我来答
百度网友75d9dce1c
2011-01-01 · TA获得超过521个赞
知道小有建树答主
回答量:172
采纳率:100%
帮助的人:123万
展开全部
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
迎美岁野欢微1O
2010-12-20 · TA获得超过1806个赞
知道小有建树答主
回答量:393
采纳率:0%
帮助的人:317万
展开全部
VC不懂,但是感觉程序不难,你具体要实现什么效果?
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式