GUICtrlRecvMsg
发送消息到控件,并检索 lParam(参数)信息.
GUICtrlRecvMsg ( controlID , msg [, wParam [, lParamType]] )
参数
controlID
|
使用 GUICtrlCreate...() 创建控件类函数返回的控件标识符, 或 -1 使用前面创建的控件.
|
msg(消息)
|
发送到控件的消息类型, 在 Windows 控件文档中定义.
|
wParam(参数)
|
[可选] 发送到控件的第一个整型参数.
|
lParam(参数类型)
|
[可选] 定义将返回的 lParam 类型:
0 (默认) 返回 wParam 与 lParam,
1 返回 lParam 字符串,
2 返回 lParam 的 RECT 结构.
|
返回值
成功:
|
返回 SendMessage 消息的 Windows API 返回值.
|
失败:
|
返回 0.
|
备注
此函数允许发送特殊的 Windows 消息到使用 SendMessage API 的控件.
而这些功能往往是简单的 GUICtrlRead() 与 GUICtrlUpdate...() 函数无法实现的.
若未指定 wParam 和 lParam 参数, 则函数将返回含有两个元素的数组 (LPwParam, LPlParam).
若返回 RECT 结构, 则为 4 元素数组 (Left, Top, Right, Bottom).
相关
GUICtrlSendMsg, GUICtrlUpdate...
函数示例
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
Example()
Func Example()
; Create a GUI with an edit control.
Local $hGUI = GUICreate("Example")
Local $idEdit = GUICtrlCreateEdit("Line 0" & @CRLF, 0, 0, 400, 350)
Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25)
; Set data of the edit control.
For $i = 1 To 25
GUICtrlSetData($idEdit, "Line " & $i & @CRLF, 1)
Next
; Set focus to the edit control.
GUICtrlSetState($idEdit, $GUI_FOCUS)
; Display the GUI.
GUISetState(@SW_SHOW, $hGUI)
; Initialize the variable $aCtrlRecvMsg for storing the value returned by GUICtrlRecvMsg.
Local $aCtrlRecvMsg = 0
; Loop until the user exits.
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $idOK
; Send the message EM_GETSEL, to retrieve the current selection of the edit control.
$aCtrlRecvMsg = GUICtrlRecvMsg($idEdit, $EM_GETSEL)
; Set focus to the edit control.
GUICtrlSetState($idEdit, $GUI_FOCUS)
; If GUICtrlRecvMsg returned the value of 0, then an error occurred otherwise display the contents of the array.
If $aCtrlRecvMsg = 0 Then
MsgBox($MB_SYSTEMMODAL, "", "An error occurred. The value returned was - " & $aCtrlRecvMsg)
Else
MsgBox($MB_SYSTEMMODAL, "", "Start: " & $aCtrlRecvMsg[0] & " End: " & $aCtrlRecvMsg[1])
EndIf
EndSwitch
WEnd
; Delete the previous GUI and all controls.
GUIDelete($hGUI)
EndFunc ;==>Example
----------------------------------------
|