# Path: venster/lib/form.py
# EXIT_NONE = 0
# EXIT_ONDESTROY = 1 #exit app on destroy of form
# EXIT_ONLASTDESTROY = 2 #exit app on destroy of last form
# ID_NEW = 5001
# ID_OPEN = 5002
# ID_EXIT = 5003
# ID_SAVE = 5004
# ID_SAVEAS = 5005
# ID_CLOSE = 5006
# ID_UNDO = 5101
# ID_REDO = 5102
# ID_COPY = 5103
# ID_PASTE = 5104
# ID_CUT = 5105
# ID_SELECTALL = 5106
# ID_CLEAR = 5107
# ID_HELP_CONTENTS = 5201
# ID_ABOUT = 5202
# CTRL_VIEW = "form_CtrlView"
# CTRL_STATUSBAR = "form_CtrlStatusBar"
# CTRL_COOLBAR = "form_CtrlCoolbar"
# class Controls(dict):
# class Form(Window):
#     class CmdUIUpdateEvent(object):
# class CMD_UI_UPDATE(object):
#     def Add(self, *args):
#     def dispose(self):
#     def __getattr__(self, key):
#     def __init__(self, *args, **kwargs):
#     def dispose(self):
#     def CreateAccels(self):
#     def PreTranslateMessage(self, msg):
#     def OnMenuSelect(self, event):
#         def __init__(self):
#         def Enable(self, fEnable):
#     def OnInitMenuPopup(self, event):
#     def DoLayout(self, cx, cy):
#     def OnDestroy(self, event):
#     def OnSize(self, event):
#     def OnCreate(self, event):
#     def OnExitCmd(self, event):
#     def OnCloseCmd(self, event):
#     def OnClose(self, event):
#     def __init__(self, id, handler):
#     def __install__(self, msgMap):
#     def __call__(self, receiver, event):
# 
# Path: venster/lib/menu.py
# def EvalItem(item, parent):
# def EvalPopupMenu(item, managed = False):
# def EvalMenu(item, managed = False):


from venster.windows import *
from venster.wtl import *
from venster.shell import *
from venster.lib import form
from venster.lib import menu
        Shell_NotifyIcon(NIM_DELETE, byref(ntfIconData))
    
    def WndProc(self, hWnd, nMsg, wParam, lParam):
        #the shell icon will send notification messages to the hidden window
        #the message is the one given by the uCallbackMessage field when the icon was
        #added to the tray.
        #the lParam contains the original msg (WM_MOUSEMOVE etc). we intercept
        #it here, and turn it into a normal msg and use normal wtl processing to handle the msg
        if nMsg == WM_USER_TASKBAR:
            nMsg = lParam
            lParam = 0
            wParam = 0
            return Window.WndProc(self, hWnd, nMsg, wParam, lParam)
        else:
            return Window.WndProc(self, hWnd, nMsg, wParam, lParam)

    def OnTaskbarCreated(self, event):
        #after an Explorer crash, this event will be received
        #when explorer restarts. Then we re-add the tray icon...
        self.AddTrayIcon()
        
    msg_handler(WM_TASKBAR_CREATED)(OnTaskbarCreated)
    
    def TrackPopupMenu(self):
        #To display a context menu for a notification icon, the 
        #current window must be the foreground window before the 
        #application calls TrackPopupMenu or TrackPopupMenuEx. Otherwise, 
        #the menu will not disappear when the user clicks outside of the 
        #menu or the window that created the menu (if it is visible). 
        self.SetForegroundWindow()

# Path: venster/lib/form.py
# EXIT_NONE = 0
# EXIT_ONDESTROY = 1 #exit app on destroy of form
# EXIT_ONLASTDESTROY = 2 #exit app on destroy of last form
# ID_NEW = 5001
# ID_OPEN = 5002
# ID_EXIT = 5003
# ID_SAVE = 5004
# ID_SAVEAS = 5005
# ID_CLOSE = 5006
# ID_UNDO = 5101
# ID_REDO = 5102
# ID_COPY = 5103
# ID_PASTE = 5104
# ID_CUT = 5105
# ID_SELECTALL = 5106
# ID_CLEAR = 5107
# ID_HELP_CONTENTS = 5201
# ID_ABOUT = 5202
# CTRL_VIEW = "form_CtrlView"
# CTRL_STATUSBAR = "form_CtrlStatusBar"
# CTRL_COOLBAR = "form_CtrlCoolbar"
# class Controls(dict):
# class Form(Window):
#     class CmdUIUpdateEvent(object):
# class CMD_UI_UPDATE(object):
#     def Add(self, *args):
#     def dispose(self):
#     def __getattr__(self, key):
#     def __init__(self, *args, **kwargs):
#     def dispose(self):
#     def CreateAccels(self):
#     def PreTranslateMessage(self, msg):
#     def OnMenuSelect(self, event):
#         def __init__(self):
#         def Enable(self, fEnable):
#     def OnInitMenuPopup(self, event):
#     def DoLayout(self, cx, cy):
#     def OnDestroy(self, event):
#     def OnSize(self, event):
#     def OnCreate(self, event):
#     def OnExitCmd(self, event):
#     def OnCloseCmd(self, event):
#     def OnClose(self, event):
#     def __init__(self, id, handler):
#     def __install__(self, msgMap):
#     def __call__(self, receiver, event):
# 
# Path: venster/lib/menu.py
# def EvalItem(item, parent):
# def EvalPopupMenu(item, managed = False):
# def EvalMenu(item, managed = False):


# Path: venster/lib/tray.py
from venster.windows import *
from venster.wtl import *
from venster.shell import *
from venster.lib import form
from venster.lib import menu

        Shell_NotifyIcon(NIM_DELETE, byref(ntfIconData))
    
    def WndProc(self, hWnd, nMsg, wParam, lParam):
        #the shell icon will send notification messages to the hidden window
        #the message is the one given by the uCallbackMessage field when the icon was
        #added to the tray.
        #the lParam contains the original msg (WM_MOUSEMOVE etc). we intercept
        #it here, and turn it into a normal msg and use normal wtl processing to handle the msg
        if nMsg == WM_USER_TASKBAR:
            nMsg = lParam
            lParam = 0
            wParam = 0
            return Window.WndProc(self, hWnd, nMsg, wParam, lParam)
        else:
            return Window.WndProc(self, hWnd, nMsg, wParam, lParam)

    def OnTaskbarCreated(self, event):
        #after an Explorer crash, this event will be received
        #when explorer restarts. Then we re-add the tray icon...
        self.AddTrayIcon()
        
    msg_handler(WM_TASKBAR_CREATED)(OnTaskbarCreated)
    
    def TrackPopupMenu(self):
        #To display a context menu for a notification icon, the 
        #current window must be the foreground window before the 
        #application calls TrackPopupMenu or TrackPopupMenuEx. Otherwise, 
        #the menu will not disappear when the user clicks outside of the 
        #menu or the window that created the menu (if it is visible). 
        self.SetForegroundWindow()

        trayMenu = menu.EvalPopupMenu(self._tray_icon_menu_, managed = True)