zuiyi 发表于 2012-5-9 17:53:16

关于托盘的菜单对应多窗体的问题

托盘中的每一个菜单,都对应一个窗体($Form)。每点击一个菜单时,打开对应的窗体,请教高手下面的代码要怎么改?或给个其它的办法。。。。Opt("GUIOnEventMode", 1)
Opt("TrayOnEventMode",1)
Opt("TrayAutoPause",0)
Opt("TrayMenuMode",1)

;双击显示界面, 右击打开菜单
TraySetClick(12)
TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE,"_TrayEvent")
TraySetOnEvent($TRAY_EVENT_SECONDARYDOWN,"_TrayEvent")
$TrayItem1= TrayCreateItem("窗体1")
TrayCreateItem("")
$TrayItem2= TrayCreateItem("窗体2")
TrayCreateItem("")
$Exit= TrayCreateItem("退出")
TrayItemSetOnEvent(-1,"_TrayEvent")
TraySetState()

#Region ### START Koda GUI section ### Form=Hsy_Shop.kxf
$Form1 = GUICreate("窗体1", 282, 162, 366, 349, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
GUISetState(@SW_HIDE, $Form1)

$Form2 = GUICreate("窗体2", 369, 169, 313, 245, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
GUISetState(@SW_HIDE, $Form2)
#EndRegion ### END Koda GUI section ###


While 1
        Sleep(100)
WEnd

;_TrayEvent
Func _TrayEvent()
        Switch @TRAY_ID
                Case $TrayItem1
                        GUISetState(@SW_SHOW, $Form1)
                Case $TrayItem2
                        GUISetState(@SW_SHOW, $Form2)
                Case $Exit
                        _Exit()
        EndSwitch       
EndFunc

;_GUIEvent
Func _GUIEvent()       
EndFunc

veket_linux 发表于 2012-5-9 22:01:16

TrayItemSetOnEvent

veket_linux 发表于 2012-5-9 22:03:58

#include <Constants.au3>;;;;;;;
#include <WindowsConstants.au3> ;;;;;;;


Opt("GUIOnEventMode", 1)
Opt("TrayOnEventMode",1)
Opt("TrayAutoPause",0)
Opt("TrayMenuMode",1)

;双击显示界面, 右击打开菜单
TraySetClick(12)
TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE,"_TrayEvent")
TraySetOnEvent($TRAY_EVENT_SECONDARYDOWN,"_TrayEvent")
$TrayItem1= TrayCreateItem("窗体1")
TrayItemSetOnEvent($TrayItem1,"TrayItem1_Clicked");;;;;;;
TrayCreateItem("")
$TrayItem2= TrayCreateItem("窗体2")
TrayItemSetOnEvent($TrayItem2,"TrayItem2_Clicked");;;;;;;
TrayCreateItem("")
$Exit= TrayCreateItem("退出")
TrayItemSetOnEvent(-1,"_TrayEvent")
TraySetState()

#Region ### START Koda GUI section ### Form=Hsy_Shop.kxf
$Form1 = GUICreate("窗体1", 282, 162, 366, 349, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
GUISetState(@SW_HIDE, $Form1)

$Form2 = GUICreate("窗体2", 369, 169, 313, 245, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
GUISetState(@SW_HIDE, $Form2)
#EndRegion ### END Koda GUI section ###


While 1
      Sleep(100)
WEnd

;_TrayEvent
Func _TrayEvent()
      Switch @TRAY_ID
                Case $TrayItem1
                        GUISetState(@SW_SHOW, $Form1)
                Case $TrayItem2
                        GUISetState(@SW_SHOW, $Form2)
                Case $Exit
                        Exit;;;;;
      EndSwitch      
EndFunc

;_GUIEvent
Func _GUIEvent()
       
EndFunc

Func TrayItem1_Clicked();;;;;;;;;;;;;
        GUISetState(@SW_SHOW, $Form1)
        GUISetState(@SW_HIDE, $Form2)
EndFunc

Func TrayItem2_Clicked();;;;;;;;;;;;;;
        GUISetState(@SW_HIDE, $Form1)
        GUISetState(@SW_SHOW, $Form2)
EndFunc

zuiyi 发表于 2012-5-10 03:59:04

{:face (207):}谢楼上的,思考太多头脑发热,竟忘记注册点击事件了。。。

qq82015930 发表于 2012-6-8 01:04:42

用托盘的不多呵呵
页: [1]
查看完整版本: 关于托盘的菜单对应多窗体的问题