如何在VB中实现对TEXTBOX的自动滚屏?
text1设置为多行,scrollbars设置为bothtext2每一次输入的内容,分行显示到text1中.请教的问题:竖着的滚动条怎样能固定在最下方而不是最上方?在te...
text1设置为多行,scrollbars 设置为both
text2 每一次输入的内容,分行显示到text1中.
请教的问题:竖着的滚动条怎样能固定在最下方而不是最上方?在textbox里显示最新text2.输入的内容,以前的内容能回到上面去.(类似聊天室?)
如果用其他控件实现这个滚动,也可以.
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const EM_GETLINECOUNT = &HBA
Private Const EM_LINESCROLL = &HB6
Private Sub Command1_Click()
Text1.Text = Text1.Text + Text2.Text
Text1.Text = Text1.Text + vbCrLf
Dim ScrollAmount As Long
Dim rc2 As Long
'得到总行数
ScrollAmount = SendMessage(Text1.hwnd, EM_GETLINECOUNT, 0, 0)
'MsgBox rc
'滚动到指定行和列
rc2 = SendMessage(Text1.hwnd, EM_LINESCROLL, 0, ByVal ScrollAmount&)
End Sub
---- 展开
text2 每一次输入的内容,分行显示到text1中.
请教的问题:竖着的滚动条怎样能固定在最下方而不是最上方?在textbox里显示最新text2.输入的内容,以前的内容能回到上面去.(类似聊天室?)
如果用其他控件实现这个滚动,也可以.
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const EM_GETLINECOUNT = &HBA
Private Const EM_LINESCROLL = &HB6
Private Sub Command1_Click()
Text1.Text = Text1.Text + Text2.Text
Text1.Text = Text1.Text + vbCrLf
Dim ScrollAmount As Long
Dim rc2 As Long
'得到总行数
ScrollAmount = SendMessage(Text1.hwnd, EM_GETLINECOUNT, 0, 0)
'MsgBox rc
'滚动到指定行和列
rc2 = SendMessage(Text1.hwnd, EM_LINESCROLL, 0, ByVal ScrollAmount&)
End Sub
---- 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询