病毒专收员 发表于 2009-7-24 19:46:38

GUICtrlCreateEdit 中如何移动 插入符(caret,光标) 到指定位置!

本帖最后由 病毒专收员 于 2009-7-24 23:09 编辑

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("窗体1", 413, 305, 302, 218)
$Edit1 = GUICtrlCreateEdit("", 0, 0, 409, 297)
GUICtrlSetData(-1, "Edit1",1)
GUICtrlSetData(-1, "Edit1",1)
GUICtrlSetData(-1, "Edit1",1)
GUICtrlSetData(-1, "Edit1",1)
GUICtrlSetData(-1, "Edit6",1)
GUICtrlSetData(-1, "Edit1",1)
GUICtrlSetData(-1, "Edit1",1)
GUICtrlSetData(-1, "Edit1",1)
GUICtrlSetData(-1, "Edit1",1)
GUICtrlSetData(-1, "Edit1",1)
GUICtrlSetData(-1, "Edit1",1)
GUISetState(@SW_SHOW)


While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd


如何控制 插入符(caret,光标) 移动到文本 Edit6 后面

大绯狼 发表于 2009-7-24 20:42:25

_GUICtrlEdit_SetSel($Edit1, 2, 2)

pusofalse 发表于 2009-7-24 21:55:02

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("窗体1", 413, 305, 302, 218)
$Edit1 = GUICtrlCreateEdit("", 0, 0, 409, 297)
GUICtrlSetData(-1, "Edit1",1)
GUICtrlSetData(-1, "Edit1",1)
GUICtrlSetData(-1, "Edit1",1)
GUICtrlSetData(-1, "Edit1",1)
GUICtrlSetData(-1, "Edit6",1)
GUICtrlSetData(-1, "Edit1",1)
GUICtrlSetData(-1, "Edit1",1)
GUICtrlSetData(-1, "Edit1",1)
GUICtrlSetData(-1, "Edit1",1)
GUICtrlSetData(-1, "Edit1",1)
GUICtrlSetData(-1, "Edit1",1)
GUISetState(@SW_SHOW)

GUICtrlSetState(-1, $GUI_FOCUS)


Sleep(2000)
_SetCaretPos(200, 1)
Sleep(2000)
_SetCaretPos(50, 1)



While 1
      $nMsg = GUIGetMsg()
      Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

      EndSwitch
WEnd

Func _GetCaretPos()
        Local $aXY, $iResult, $tBuffer

        $tBuffer = DllStructCreate("int X;int Y")
        $iResult = DllCall("User32.dll", "int", "GetCaretPos", "ptr", DllStructGetPtr($tBuffer))
        $aXY = DllStructGetData($tBuffer, "X")
        $aXY = DllStructGetData($tBuffer, "Y")
        Return $aXY
EndFunc        ;==>_GetCaretPos

Func _SetCaretPos($iX, $iY)
        Local $iResult
        $iResult = DllCall("User32.dll", "int", "SetCaretPos", "int", $iX, "int", $iY)
        Return $iResult <> 0
EndFunc        ;==>_SetCaretPos

lynfr8 发表于 2009-7-24 22:00:42

不错,控制插入符的例子不多,学习下

病毒专收员 发表于 2009-7-24 23:08:40

good~`` 感谢大家!
页: [1]
查看完整版本: GUICtrlCreateEdit 中如何移动 插入符(caret,光标) 到指定位置!