# Function Reference

GUICtrlSendMsg

Send a message to a control.

GUICtrlSendMsg ( controlID, msg , wParam, lParam )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate... function.
msg | type of message to be send to the control as defined in the Windows control documentation.
wParam | The first param to send to the control.
lParam | The second param to send to the control.

Return Value

Success: | Returns the value returned by the SendMessage Windows API.
Failure: | Returns 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 GUICtrlSet...() range of functions.
The parameters (wParam and lParam) can be an integer or a string.
GUICtrlSendMsg should be used for messages that have no special return types. For more advanced messages where you must be able to receive extra data you must use GUICtrlRecvMsg().

Related

GUICtrlRecvMsg, GUICtrlCreate..., GUICtrlSet..., GUIGetMsg, GUICtrlRead

Example

#include <GUIConstants.au3>
GUICreate("My GUI") ; will create a dialog box that when displayed is centered
$nEdit = GUICtrlCreateEdit ("line 0", 10,10)
GUICtrlCreateButton ("Ok", 20,200,50)
GUISetState ()
for $n=1 to 5
GUICtrlSetData ($nEdit,@CRLF & "line "& $n)
next
$EM_LINEINDEX = 0x00BB
$EM_LINEFROMCHAR = 0x00C9
; Run the GUI until the dialog is closed
Do
$msg = GUIGetMsg()
if $msg >0 then
$n=GUICtrlSendMsg ($nEdit, $EM_LINEINDEX,-1,0)
$nline=GUICtrlSendMsg( $nEdit, $EM_LINEFROMCHAR,$n,0)
GUICtrlSetState ($nEdit,256) ; set focus
MsgBox (0,"Currentline",$nLine)
endif
Until $msg = $GUI_EVENT_CLOSE