-rw-r--r-- | Trayer.cpp | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/Trayer.cpp b/Trayer.cpp new file mode 100644 index 0000000..cf2a8ac --- a/dev/null +++ b/Trayer.cpp | |||
@@ -0,0 +1,94 @@ | |||
1 | // Trayer.cpp : implementation file | ||
2 | // | ||
3 | |||
4 | #include "stdafx.h" | ||
5 | #include "KLog.h" | ||
6 | #include "Trayer.h" | ||
7 | |||
8 | #include "SyslogSocket.h" | ||
9 | #include "KLogDlg.h" | ||
10 | |||
11 | #ifdef _DEBUG | ||
12 | #define new DEBUG_NEW | ||
13 | #undef THIS_FILE | ||
14 | static char THIS_FILE[] = __FILE__; | ||
15 | #endif | ||
16 | |||
17 | ///////////////////////////////////////////////////////////////////////////// | ||
18 | // CTrayer | ||
19 | |||
20 | CTrayer::CTrayer() | ||
21 | { | ||
22 | m_inMenu=0; | ||
23 | } | ||
24 | |||
25 | CTrayer::~CTrayer() | ||
26 | { | ||
27 | } | ||
28 | |||
29 | |||
30 | BEGIN_MESSAGE_MAP(CTrayer, CWnd) | ||
31 | //{{AFX_MSG_MAP(CTrayer) | ||
32 | ON_MESSAGE(WM_TRAYICON, OnTray) | ||
33 | ON_COMMAND(ID_TRAY_ABOUTKLOG, OnTrayAboutklog) | ||
34 | ON_COMMAND(ID_TRAY_EXIT, OnTrayExit) | ||
35 | ON_COMMAND(ID_TRAY_HELP, OnTrayHelp) | ||
36 | ON_COMMAND(ID_TRAY_SHOWKLOGWINDOW, OnTrayShowklogwindow) | ||
37 | //}}AFX_MSG_MAP | ||
38 | END_MESSAGE_MAP() | ||
39 | |||
40 | |||
41 | ///////////////////////////////////////////////////////////////////////////// | ||
42 | // CTrayer message handlers | ||
43 | |||
44 | CTrayer::CTrayer(CKLogDlg* daddy) | ||
45 | : m_inMenu(0), m_Daddy(daddy) | ||
46 | { | ||
47 | } | ||
48 | |||
49 | LRESULT CTrayer::OnTray(WPARAM wP,LPARAM lP) | ||
50 | { | ||
51 | ASSERT(wP==IDC_TRAYICON); | ||
52 | switch(lP){ | ||
53 | case WM_RBUTTONDOWN: | ||
54 | { | ||
55 | CMenu menu; | ||
56 | VERIFY(menu.LoadMenu(IDD_KLOG_DIALOG)); | ||
57 | CMenu *popUp = menu.GetSubMenu(1); | ||
58 | ASSERT(popUp); | ||
59 | CPoint pt; | ||
60 | VERIFY(::GetCursorPos(&pt)); | ||
61 | m_inMenu++; | ||
62 | SetForegroundWindow(); | ||
63 | popUp->CheckMenuItem(ID_TRAY_SHOWKLOGWINDOW,MF_BYCOMMAND|(IsWindowVisible()?MF_CHECKED:MF_UNCHECKED)); | ||
64 | popUp->TrackPopupMenu(TPM_RIGHTALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON,pt.x,pt.y,this); | ||
65 | m_inMenu--; | ||
66 | SendMessage(WM_NULL); | ||
67 | } | ||
68 | break; | ||
69 | case WM_LBUTTONDOWN: | ||
70 | m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_SHOWKLOGWINDOW); | ||
71 | break; | ||
72 | } | ||
73 | return 0; | ||
74 | } | ||
75 | |||
76 | void CTrayer::OnTrayAboutklog() | ||
77 | { | ||
78 | m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_ABOUTKLOG); | ||
79 | } | ||
80 | |||
81 | void CTrayer::OnTrayExit() | ||
82 | { | ||
83 | m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_EXIT); | ||
84 | } | ||
85 | |||
86 | void CTrayer::OnTrayHelp() | ||
87 | { | ||
88 | m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_HELP); | ||
89 | } | ||
90 | |||
91 | void CTrayer::OnTrayShowklogwindow() | ||
92 | { | ||
93 | m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_SHOWKLOGWINDOW); | ||
94 | } | ||