函数参考


_GUICtrlEdit_CharFromPos

获取客户区中距指定点最近的字符的信息

#include <GuiEdit.au3>
_GUICtrlEdit_CharFromPos($hWnd, $iX, $iY)

参数

$hWnd 控件的控件ID/句柄
$iX 水平位置
$iY 垂直位置

返回值

成功: 返回如下格式的数组:
    [0] - 最接近指定点的字符 0 基索引
    [1] - 字符所在行的 0 基索引

注意/说明

None.

相关

示例/演示


#include <GuiEdit.au3>
#include <GUIConstantsEx.au3>

$Debug_Ed = False ; Check ClassName being passed to Edit functions, set to True and use a handle to another control to see it work

_Main()

Func _Main()
    Local $aCharPos[2], $hEdit

    ; 创建 GUI
    GUICreate("Edit Char From Pos", 400, 300)
    $hEdit = GUICtrlCreateEdit("This is a test" & @CRLF & "Another Line", 2, 2, 394, 268)
    GUISetState()

    _GUICtrlEdit_AppendText($hEdit, @CRLF & "Append to the end?")

    $aCharPos = _GUICtrlEdit_CharFromPos($hEdit, 100, 20)
    MsgBox(4160, "信息", StringFormat("Char Nearsest Point: [%2d]", $aCharPos[0]) & @LF & _
            StringFormat("Line Nearest Point: [%2d]", $aCharPos[1]))

    ; 循环直到用户退出
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>_Main