'添加 textbox label1
'设置 Text1.MultiLine = True Text1.ScrollBars = 2
Option Explicit
Private Declare Function SendMessageLong Lib user32 Alias SendMessageA (ByVal hwnd As Long, ByVal wMsg As Long, wParam As Long, lParam As Long) As Long
Private Const EM_LINEINDEX = &HBB
Private Const EM_LINEFROMCHAR = &HC9
Private Const EM_GETSEL = &HB0
Private Const EM_GETLINECOUNT = &HBA
'
'函 数 名 CalcALine
'输 入 Thwnd(Long) -textbox 的 hwnd
' SumRow(Long) -求得的 总共行数
' Optional y(Long) -求得的 光标所在行数
' Optional x(Long) -求得的 光标所在例数
'输 出 无
'作 用
'作 者 石陆
'制作日期 2008 04 24
'修 改
'修改日期
'石陆软件屋 http://www.cnng.net
'
Public Sub CalcALine(Thwnd As Long, SumRow As Long, Optional y As Long, Optional x As Long)
'石陆软件屋 http://baidu.bzzo.net
Dim LPos As Long, L1 As Long, L2 As Long
SumRow = SendMessageLong(Thwnd, EM_GETLINECOUNT, 0&, 0&)
LPos = SendMessageLong(Thwnd, EM_LINEINDEX, ByVal -1, ByVal 0)
y = SendMessageLong(Thwnd, EM_LINEFROMCHAR, ByVal LPos, ByVal 0) + 1
SendMessageLong Thwnd, EM_GETSEL, L1, L2
x = L1 - LPos + 1
End Sub
Private Sub Text1_Change()
Dim LineCount As Long, Row As Long, Col As Long
CalcALine Text1.hwnd, LineCount, Row, Col
Label1.Caption = LineCount & & Row & & Col
End Sub
Private Sub Text1_Click()
Text1_Change
End Sub
相关链接:文本筐 | 总共行数 | 光标所在行数 | 光标所在例数,vb,文档
[本日志由 admin 于 2013-11-01 10:59 PM 编辑]
引用通告地址 (0):
http://www.cnng.net/blog/trackback.asp?tbID=59
http://www.cnng.net/blog/trackback.asp?tbID=59&CP=GBK
http://www.cnng.net/blog/trackback.asp?tbID=59
http://www.cnng.net/blog/trackback.asp?tbID=59&CP=GBK