函数参考


GUICtrlSendToDummy

向指定的 Dummy(虚拟) 控件发送消息

GUICtrlSendToDummy ( 控件ID [, 状态] )

参数

控件ID 控件标识符(控件ID),可由 GUICtrlCreateDummy 的返回值获得.
状态 [可选参数] 可在稍后(的脚本语句中)能使用由 GUICtrlRead 读取的值.

返回值

成功: 返回值为1.
失败: 返回值为0.

注意/说明

本函数被调用时将产生一个可在消息循环期间或由某个 OnEvent 函数(捕获并)处理的通知消息(就好像这个虚拟的控件本身被"点击"了一样).

相关

GUICtrlCreateDummy, GUICtrlSetOnEvent, GUICtrlRead

示例/演示


#include <GUIConstantsEx.au3>

Global $iUserDummy

Example()

Func Example()
    Opt("GUIOnEventMode", 1) ; Set the option to use GUIOnEventMode.

    GUICreate("GUISendToDummy", 220, 200, 100, 200)
    GUISetBkColor(0x00E0FFFF) ; Change the background color of the GUI.
    GUISetOnEvent($GUI_EVENT_CLOSE, "OnClick") ; Set an event to call the 'OnClick' function when the GUI close button is selected.

    $iUserDummy = GUICtrlCreateDummy()
    GUICtrlSetOnEvent(-1, "OnExit") ; Set an event to call the 'OnExit' function when this control is selected.

    GUICtrlCreateButton("Close", 70, 170, 85, 25)
    GUICtrlSetOnEvent(-1, "OnClick") ; Set an event to call the 'OnClick' function when this control is selected.

    ; Display the GUI.
    GUISetState(@SW_SHOW)

    While 1
        Sleep(100)
    WEnd
EndFunc   ;==>Example

Func OnClick()
    Return GUICtrlSendToDummy($iUserDummy) ; Send a message to the dummy control that the close button was selected, which will then proceed to call the function 'OnExit'.
EndFunc   ;==>OnClick

Func OnExit()
    Exit ; Exit the script.
EndFunc   ;==>OnExit