看看这个示例
#include <ie.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <ScrollBarConstants.au3>
#include <WinAPI.au3>
$WinMain = GUICreate("hello", 510, 510)
$MainMsgBoardInput = _GUICtrlEdit_Create($WinMain, "", 5, 450, 498, 21, BitOR($ES_MULTILINE, $ES_WANTRETURN, $ES_AUTOVSCROLL))
$oMainIE = _IECreateEmbedded()
GUICtrlCreateObj($oMainIE, 1, 1, 498, 435)
$backspace = GUICtrlCreateDummy()
Dim $AccelKeys[1][2] = [["{BACKSPACE}", $backspace]]
GUISetAccelerators($AccelKeys, $WinMain)
_IENavigate($oMainIE, "about:blank")
GUISetState(@SW_SHOW)
While 1
$mMsg = GUIGetMsg()
Switch $mMsg
Case $backspace
If _WinAPI_GetFocus() = $MainMsgBoardInput Then
$out = _GUICtrlEdit_GetText($MainMsgBoardInput)
_GUICtrlEdit_SetText($MainMsgBoardInput, StringTrimRight($out, 1))
_GUICtrlEdit_SetPos($MainMsgBoardInput, -1, -1)
EndIf
Case -3
Exit
EndSwitch
WEnd
Func _GUICtrlEdit_SetPos($hWnd, $iLine, $iColumn = 0)
If Not IsHWnd($hWnd) Then
$hWnd = GUICtrlGetHandle($hWnd)
If $hWnd = 0 Then
Return SetError(1, 0, 0)
EndIf
EndIf
Local $Lenght, $Num = 0, $Count = _GUICtrlEdit_GetLineCount($hWnd)
If $iLine > $Count - 1 Then
$Num = _GUICtrlEdit_GetTextLen($hWnd)
Else
If $iLine < 0 Then
$iLine = $Count - 1
EndIf
For $i = 0 To $iLine - 1
$Num += _GUICtrlEdit_LineLength($hWnd, $i) + 2 ; + @CR + @LF
Next
$Lenght = _GUICtrlEdit_LineLength($hWnd, $iLine)
If ($iColumn < 0) Or ($iColumn > $Lenght) Then
$iColumn = $Lenght
EndIf
$Num += $iColumn
EndIf
_GUICtrlEdit_SetSel($hWnd, $Num, $Num)
_GUICtrlEdit_Scroll($hWnd, $SB_SCROLLCARET)
Return 1
EndFunc ;==>_GUICtrlEdit_SetPos
|