是这样吗?
Global $SC_CLOSE = 0xF060
Global $WM_SYSCOMMAND = 0x112
Global $GUI_RUNDEFMSG = 'GUI_RUNDEFMSG'
$MAIN = GUICreate('MAIN', 600, 500)
$LA = GUICtrlCreateButton('A:新增子窗', 10, 50, 120, 30)
$LB = GUICtrlCreateButton('B:子窗產生後 點我是否有反應', 10, 100, 200, 30)
GUISetState(@SW_SHOW)
$SUB = GUICreate('SUB', 500, 400, -1, -1, -1, -1, $MAIN)
$KB = GUICtrlCreateButton('C:子窗按鈕', 10, 100, 200, 30)
GUISetState(@SW_HIDE)
GUIRegisterMsg($WM_SYSCOMMAND, 'WM_SYSCOMMAND')
While 1
Switch GUIGetMsg()
Case $LA
GUISwitch($SUB)
GUISetState(@SW_SHOW, $SUB)
Case $LB
GUISwitch($MAIN)
MsgBox(0, "A", "可以看到我嗎??")
Case $KB
GUISwitch($SUB)
MsgBox(0, "B", "我是子窗 主窗能後有反應嗎??")
EndSwitch
WEnd
Func WM_SYSCOMMAND($hWnd, $sMsg, $sWParam, $slParam)
Switch $hWnd
Case $MAIN
Switch $sWParam
Case $SC_CLOSE
Exit
EndSwitch
Case $SUB
Switch $sWParam
Case $SC_CLOSE
GUISetState(@SW_HIDE, $SUB)
GUISwitch($MAIN)
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_SYSCOMMAND
|