那么你……
GetCaretPos
VB声明
Declare Function GetCaretPos Lib "user32" Alias "GetCaretPos" (lpPoint As POINTAPI) As Long
说明
判断插入符的当前位置
返回值
Long,非零表示成功,零表示失败。会设置GetLastError
参数表
参数 类型及说明
lpPoint POINTAPI,这个结构会随同插入符在窗口客户坐标系统中的位置载入;那个窗口是插入符的父窗口
注意系统中 那个会闪烁的插入符,坐标是 像素哦,至于像素->文本位置坐标,你需要结合 字体高度、滚动条的属性才能计算出……
获取滚动条的属性的API我还没用过,就不说了……
程序代码: | [ 复制代码 ] |
Private Declare Function GetCaretPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private Sub Command1_Click()
Dim s As POINTAPI
GetCaretPos s
Label1.Caption = s.x & "," & s.y
Command2.Left = s.x * 15
End Sub
Private Type POINTAPI
x As Long
y As Long
End Type
Private Sub Command1_Click()
Dim s As POINTAPI
GetCaretPos s
Label1.Caption = s.x & "," & s.y
Command2.Left = s.x * 15
End Sub
相关链接:vb | 插入符 | 光标 | 坐标
[本日志由 admin 于 2013-11-01 10:53 PM 编辑]
引用通告地址 (0):
http://www.cnng.net/blog/trackback.asp?tbID=44
http://www.cnng.net/blog/trackback.asp?tbID=44&CP=GBK
http://www.cnng.net/blog/trackback.asp?tbID=44
http://www.cnng.net/blog/trackback.asp?tbID=44&CP=GBK