1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
//
// AUTHOR
// Stef Walter
//
// LICENSE
// This software is in the public domain.
//
// The software is provided "as is", without warranty of any kind,
// express or implied, including but not limited to the warranties
// of merchantability, fitness for a particular purpose, and
// noninfringement. In no event shall the author(s) be liable for any
// claim, damages, or other liability, whether in an action of
// contract, tort, or otherwise, arising from, out of, or in connection
// with the software or the use or other dealings in the software.
//
// SUPPORT
// Send bug reports to: <stef@memberwebs.com>
//
#ifndef __MONITORDLG_H_
#define __MONITORDLG_H_
#include "resource.h" // main symbols
#include "trayicon.h"
#define WM_TRAYICON (WM_APP + 38L)
#include "regsettings.h"
#include "persistwinpos.h"
#define TIME_LAPSE 4000
#define LAPSE_PER_MIN 15
#define CHARS_PER_WORD 544
#define CHARS_MULTIPLE 100
/////////////////////////////////////////////////////////////////////////////
// CMonitorDlg
class CMonitorDlg :
public CDialogImpl<CMonitorDlg>,
public CPersistPosWindow<CMonitorDlg>
{
public:
CMonitorDlg();
~CMonitorDlg();
enum { IDD = IDD_MONITORDLG };
BEGIN_MSG_MAP(CMonitorDlg)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_HANDLER(IDC_ONTOP, BN_CLICKED, OnTop)
COMMAND_ID_HANDLER(IDOK, OnOK)
COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
MESSAGE_HANDLER(WM_TIMER, OnTimer)
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
COMMAND_ID_HANDLER(ID_TRAY_EXIT, OnExit)
COMMAND_ID_HANDLER(ID_TRAY_SHOW, OnShow)
MESSAGE_HANDLER(WM_TRAYICON, OnTrayIcon)
END_MSG_MAP()
// Handler prototypes:
// LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
// LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
// LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
LRESULT OnTop(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnShow(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnExit(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
// Notification from Icon
LRESULT OnTrayIcon(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{ return m_Icon.OnTrayNotification(wParam, lParam); }
protected:
bool CreateIcon(long lSpeed, long lAverage);
long GetAverage(long lSpeed);
HICON m_hIcon;
SIZE m_szIcon;
CImageList m_imgList;
CTrayIcon m_Icon; // Icon in Shell Tray
CRegSettings m_settings; // Our registry key
long m_aSpeeds[LAPSE_PER_MIN];
int m_nIndex;
};
#endif //__MONITORDLG_H_
|