Function Reference


GUICtrlRecvMsg

Send a message to a control and retrieve information in lParam.

GUICtrlRecvMsg ( controlID , msg [, wParam [, lParamType]] )

Parameters

controlID The control identifier (controlID) as returned by a GUICtrlCreate...() function, or -1 for the last created control.
msg type of message to be send to the control as defined in the Windows controls documentation.
wParam [optional] An integer first param to be send to the control.
lParamType [optional] Define the type of lParam that will be returned: 0 (default) for wParam and lParam, 1 for lParam String, 2 for lParam RECT struct.

Return Value

Success: the value returned by the SendMessage Windows API.
Failure: 0.

Remarks

This function allows the sending of special Windows messages directly to the control using the SendMessage API. It is used to enable special control features not available with the simple GUICtrlRead() and GUICtrlUpdate... range of functions.

If the wParam and lParamType parameters are not specified then an array of two elements is returned (LPwParam, LPlParam).

The RECT is returned in an array of 4 elements (Left, Top, Right, Bottom).

Related

GUICtrlSendMsg, GUICtrlUpdate...

Example

#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 $idButton_Ok = 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 $idButton_Ok
                                ; 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