#include <IE.au3>
#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
Opt("GUICloseOnESC", 0);取消esc退出
Opt("TrayMenuMode", 3) ; 默认托盘菜单项目将不会显示, 当选定项目时也不检查. TrayMenuMode 的其它选项为 1, 2.
Global Enum $e_idOpen = 1000, $e_idSave, $e_idInfo
Local $hMainGUI, $hDateGUI
Local $idExit = TrayCreateItem("退出")
MainGUI()
; 注册消息处理程序
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
GUIRegisterMsg($WM_CONTEXTMENU, "WM_CONTEXTMENU")
GUIRegisterMsg($WM_SYSCOMMAND, "WM_SYSCOMMAND")
; 循环到用户退出.
Do
Switch TrayGetMsg()
Case $idExit ; 退出循环.
ExitLoop
EndSwitch
Until 0
Func MainGUI()
; 创建 GUI
$hMainGUI = GUICreate("主GUI", 400, 200)
$idLabel = GUICtrlCreateLabel('Label控件', 2, 2, 350, 196, BitOR($SS_CENTER,$WS_BORDER), $GUI_WS_EX_PARENTDRAG) ;$SS_CENTER 文本居中,设置$GUI_WS_EX_PARENTDRAG,按住本控件可拖动窗口
GUICtrlSetFont(-1, 16, 500, Default, '微软雅黑') ; 设置上面控件的字体.
GUICtrlSetBkColor(-1, 0x000000) ;控件的背景色
GUICtrlSetColor(-1, 0x00FF00) ;控件的文本颜色
GUISetState(@SW_SHOW)
EndFunc ;==>MainGUI
Func _Date()
$oIE = _IECreateEmbedded()
$hDateGUI = GUICreate("万年历", 622, 450, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)
$GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, 622, 450)
GUISetState(@SW_SHOW)
_IENavigate ($oIE,"http://www.jxteacher.com/userfiles/plyt2011/flash/2014061413444395.swf")
#cs
Local $nMsg
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
MsgBox(0,0,'测试$GUI_EVENT_CLOSE消息')
ExitLoop
EndSwitch
WEnd
$oIE = 0
GUISetState(@SW_HIDE, $hDateGUI)
GUIDelete($hDateGUI)
#ce
EndFunc ;==>_Date
; 处理 WM_COMMAND 消息
Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
#forceref $hWnd, $iMsg, $lParam
Switch $wParam
Case $e_idOpen
;_WinAPI_ShowMsg("你点击了 [打开] 菜单")
_Date() ;显示万年历
Case $e_idSave
_WinAPI_ShowMsg("你点击了 [保存] 菜单")
Case $e_idInfo
_WinAPI_ShowMsg("你点击了 [信息] 菜单")
EndSwitch
EndFunc ;==>WM_COMMAND
; 处理 WM_CONTEXTMENU 消息
Func WM_CONTEXTMENU($hWnd, $iMsg, $wParam, $lParam)
#forceref $hWnd, $iMsg, $lParam
Local $hMenu
$hMenu = _GUICtrlMenu_CreatePopup()
_GUICtrlMenu_InsertMenuItem($hMenu, 0, "打开万年历", $e_idOpen)
_GUICtrlMenu_InsertMenuItem($hMenu, 1, "保存", $e_idSave)
_GUICtrlMenu_InsertMenuItem($hMenu, 3, "", 0)
_GUICtrlMenu_InsertMenuItem($hMenu, 3, "信息", $e_idInfo)
;_GUICtrlMenu_TrackPopupMenu($hMenu, $wParam)
_GUICtrlMenu_TrackPopupMenu($hMenu, $hWnd) ;谢谢 A大出手指点!
_GUICtrlMenu_DestroyMenu($hMenu)
Return True
EndFunc ;==>WM_CONTEXTMENU
Func WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
Local $nID = BitAND($wParam, 0x0000FFFF)
Switch $nID
Case $SC_CLOSE
;If $hWnd = $hMainGUI Then
; Exit
;Else
GUIDelete($hWnd)
;EndIf
EndSwitch
EndFunc ;==>WM_SYSCOMMAND