|
本帖最后由 touch_xu 于 2014-10-15 17:37 编辑
我想做的事就是,在B窗口中用事件模式监控A窗口中的label控件值变化并同步更新.
A窗口代码如下, 就是用OK产生随机数:#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("A", 179, 126, 192, 124)
$Label1 = GUICtrlCreateLabel(Random(30, 50, 1), 0, 24, 180, 16, $SS_CENTER)
$Button1 = GUICtrlCreateButton("OK", 32, 80, 115, 25)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
GUICtrlSetData($Label1, Random(30, 50, 1))
EndSwitch
WEnd
B窗口代码,就是监控A窗口的随机数变化, 并同步更新, 不用轮询模式:#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=
$Form2 = GUICreate("B", 179, 126, 192, 124)
$Label2 = GUICtrlCreateLabel("0", 0, 24, 180, 16, $SS_CENTER)
GUICtrlSetOnEvent(-1, "_GuiEvent")
GUISetOnEvent($GUI_EVENT_CLOSE, "_GuiEvent")
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
Opt('GUIResizeMode', 802)
Opt("GUIOnEventMode", 1)
$CtrlHandle = ControlGetHandle("A", "", "Static1")
GUICtrlSetOnEvent(-1, "_GuiEvent")
While 1
Sleep(90)
WEnd
Func _GuiEvent()
Switch @GUI_CtrlId
Case $GUI_EVENT_CLOSE
Exit
Case $CtrlHandle
GUICtrlSetData($Label2, ControlGetText($CtrlHandle, "", "Static1"))
EndSwitch
EndFunc ;==>_GuiEvent
大家帮我看下能不能实现,错在什么地方,谢谢! |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?加入
×
|