vb statusbar怎么显示当前鼠标所在文本行数

vbstatusbar里面做了一个状态栏,还有一个richtextbox。要怎么做才能把richtextbox里面的鼠标所在文本行数显示到假设是statusbar1.pa... vb statusbar里面做了一个状态栏,还有一个richtextbox。要怎么做才能把richtextbox里面的鼠标所在文本行数显示到假设是statusbar1.panels(1)里面去
还有一个就是怎么计算光标所选定的文本的字数,也假设把它放到statusbar1.panels(2)里面
高手多多指教
好的定加分!!!!
展开
 我来答
百度网友e9042513a
2009-07-13 · TA获得超过6984个赞
知道大有可为答主
回答量:2388
采纳率:0%
帮助的人:3502万
展开全部
VB 6.0 获取 richtextbox当前行和列

Private Const EM_GETSEL = &HB0
Private Const EM_LINEFROMCHAR = &HC9
Private Const EM_LINEINDEX = &HBB

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 Sub GetCaretPos(ByVal TextHwnd As Long, LineNo As Long, ColNo As Long)
Dim i As Long
Dim j As Long
Dim k As Long
Dim lParam As Long
Dim wParam As Long

i = SendMessage(TextHwnd, EM_GETSEL, wParam, lParam)
j = i / 2 ^ 16

LineNo = SendMessage(TextHwnd, EM_LINEFROMCHAR, j, 0)
LineNo = LineNo + 1

k = SendMessage(TextHwnd, EM_LINEINDEX, -1, 0)
ColNo = j - k + 1
End Sub

Private Sub RichTextBox1_SelChange()
Dim LineNo As Long
Dim ColNo As Long

GetCaretPos RichTextBox1.hwnd, LineNo, ColNo
Label1.Caption = LineNo '行 状态条代码写在这里
Label2.Caption = ColNo '列

End Sub

RichTextBox 属性 SelLength 的值 就是选定的文本的字数
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
微软专家张海
2009-07-13 · TA获得超过748个赞
知道小有建树答主
回答量:564
采纳率:100%
帮助的人:0
展开全部
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

Const EM_GETFIRSTVISIBLELINE = &HCE
Const EM_LINEFROMCHAR = &HC9
Const EM_GETLINECOUNT = &HBA
Const EM_LINEINDEX = &HBB

Public Function GetLineFromChar(txtBox As RichTextBox, CharPos As Long) As Long
GetLineFromChar = SendMessage(txtBox.hwnd, EM_LINEFROMCHAR, CharPos, 0&)
End Function

StatusBar1.Panels(1).Text = GetLineFromChar(RichTextBox1, RichTextBox1.SelStart) + 1

StatusBar1.Panels(2).Text = RichTextBox1.SelLength
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式