发送一个消息到控件.
GUICtrlSendMsg ( 控件ID, msg , wParam, lParam )
控件ID | 控件标识符(控件ID),可由 GUICtrlCreate... 函数的返回值获得. |
msg | 要发送到控件的消息类型,在 Windows 的控件文档中有定义. |
wParam | 要发送到控件的第一个参数. |
lParam | 要发送到控件的第二个参数. |
成功: | 返回 SendMessage(Windows API) 的返回值. |
失败: | 返回 0. |
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
GUICreate("My GUI") ; will create a dialog box that when displayed is centered
Local $nEdit = GUICtrlCreateEdit("line 0", 10, 10)
GUICtrlCreateButton("Ok", 20, 200, 50)
GUISetState()
Local $n
For $n = 1 To 5
GUICtrlSetData($nEdit, @CRLF & "line " & $n)
Next
; Run the GUI until the dialog is closed
Do
Local $msg = GUIGetMsg()
If $msg > 0 Then
$n = GUICtrlSendMsg($nEdit, $EM_LINEINDEX, -1, 0)
Local $nline = GUICtrlSendMsg($nEdit, $EM_LINEFROMCHAR, $n, 0)
GUICtrlSetState($nEdit, $GUI_FOCUS) ; set focus
MsgBox(0, "Currentline", $nline)
EndIf
Until $msg = $GUI_EVENT_CLOSE