1 | // TrayNot.cpp : implementation file |
---|
2 | // |
---|
3 | |
---|
4 | #define BITLBEE_CORE |
---|
5 | #include "bitlbeewin.h" |
---|
6 | #include "TrayNot.h" |
---|
7 | |
---|
8 | #ifdef _DEBUG |
---|
9 | #define new DEBUG_NEW |
---|
10 | #undef THIS_FILE |
---|
11 | static char THIS_FILE[] = __FILE__; |
---|
12 | #endif |
---|
13 | |
---|
14 | ///////////////////////////////////////////////////////////////////////////// |
---|
15 | // CTrayNot dialog |
---|
16 | |
---|
17 | |
---|
18 | CTrayNot::CTrayNot(CPropertySheet *s) |
---|
19 | : CDialog(CTrayNot::IDD, NULL) |
---|
20 | { |
---|
21 | Create(CTrayNot::IDD); |
---|
22 | EnableWindow(FALSE); |
---|
23 | |
---|
24 | dlg = s; |
---|
25 | |
---|
26 | /* Traybar icon */ |
---|
27 | NOTIFYICONDATA dat; |
---|
28 | dat.cbSize = sizeof(NOTIFYICONDATA); |
---|
29 | dat.hWnd = m_hWnd; |
---|
30 | dat.uID = 1; |
---|
31 | dat.uFlags = NIF_ICON + NIF_TIP + NIF_MESSAGE; |
---|
32 | dat.hIcon = AfxGetApp()->LoadIcon(IDI_BEE); |
---|
33 | dat.uCallbackMessage = BITLBEE_TRAY_ICON; |
---|
34 | strcpy(dat.szTip, "Bitlbee manager"); |
---|
35 | Shell_NotifyIcon(NIM_ADD, &dat); |
---|
36 | |
---|
37 | //{{AFX_DATA_INIT(CTrayNot) |
---|
38 | // NOTE: the ClassWizard will add member initialization here |
---|
39 | //}}AFX_DATA_INIT |
---|
40 | } |
---|
41 | |
---|
42 | |
---|
43 | void CTrayNot::DoDataExchange(CDataExchange* pDX) |
---|
44 | { |
---|
45 | CDialog::DoDataExchange(pDX); |
---|
46 | //{{AFX_DATA_MAP(CTrayNot) |
---|
47 | // NOTE: the ClassWizard will add DDX and DDV calls here |
---|
48 | //}}AFX_DATA_MAP |
---|
49 | } |
---|
50 | |
---|
51 | ///////////////////////////////////////////////////////////////////////////// |
---|
52 | // CTrayNot message handlers |
---|
53 | |
---|
54 | CTrayNot::~CTrayNot() |
---|
55 | { |
---|
56 | NOTIFYICONDATA dat; |
---|
57 | dat.cbSize = sizeof(NOTIFYICONDATA); |
---|
58 | dat.hWnd = m_hWnd; |
---|
59 | dat.uID = 1; |
---|
60 | Shell_NotifyIcon(NIM_DELETE, &dat); |
---|
61 | } |
---|
62 | |
---|
63 | |
---|
64 | BEGIN_MESSAGE_MAP(CTrayNot, CDialog) |
---|
65 | //{{AFX_MSG_MAP(CTrayNot) |
---|
66 | // NOTE - the ClassWizard will add and remove mapping macros here. |
---|
67 | ON_MESSAGE (BITLBEE_TRAY_ICON, OnSysTrayIconClick) |
---|
68 | //}}AFX_MSG_MAP |
---|
69 | END_MESSAGE_MAP() |
---|
70 | |
---|
71 | |
---|
72 | ///////////////////////////////////////////////////////////////////////////// |
---|
73 | // CTrayNot message handlers |
---|
74 | |
---|
75 | afx_msg LONG CTrayNot::OnSysTrayIconClick (WPARAM wParam, LPARAM lParam) |
---|
76 | { |
---|
77 | switch (lParam) |
---|
78 | { |
---|
79 | case WM_LBUTTONDOWN: |
---|
80 | dlg->ShowWindow(SW_SHOW); |
---|
81 | break; |
---|
82 | case WM_RBUTTONDOWN: |
---|
83 | ShowQuickMenu (); |
---|
84 | break ; |
---|
85 | } |
---|
86 | return 0; |
---|
87 | } |
---|
88 | |
---|
89 | void CTrayNot::ShowQuickMenu() |
---|
90 | { |
---|
91 | POINT CurPos; |
---|
92 | |
---|
93 | CMenu qmenu; |
---|
94 | qmenu.LoadMenu(IDR_POPUP); |
---|
95 | |
---|
96 | GetCursorPos (&CurPos); |
---|
97 | |
---|
98 | CMenu *submenu = qmenu.GetSubMenu(0); |
---|
99 | |
---|
100 | SetForegroundWindow(); |
---|
101 | // Display the menu. This menu is a popup loaded elsewhere. |
---|
102 | |
---|
103 | submenu->TrackPopupMenu (TPM_RIGHTBUTTON | TPM_RIGHTALIGN, |
---|
104 | CurPos.x, |
---|
105 | CurPos.y,this); |
---|
106 | } |
---|