-
Notifications
You must be signed in to change notification settings - Fork 0
/
Saverwnd.cpp
136 lines (113 loc) · 2.81 KB
/
Saverwnd.cpp
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// saverwnd.cpp : implementation file
//
#include "stdafx.h"
#include "Saver.h"
#include "drawwnd.h"
#include "saverwnd.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSaverWnd
CSaverWnd::CSaverWnd()
{
m_ptLast = CPoint(-1, -1);
// m_nPos = 0;
// m_nStep = 1;
}
CSaverWnd::~CSaverWnd()
{
}
BEGIN_MESSAGE_MAP(CSaverWnd, CDrawWnd)
//{{AFX_MSG_MAP(CSaverWnd)
ON_WM_SYSCOMMAND()
ON_WM_DESTROY()
ON_WM_SETCURSOR()
ON_WM_NCACTIVATE()
ON_WM_ACTIVATE()
ON_WM_ACTIVATEAPP()
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONDOWN()
ON_WM_MBUTTONDOWN()
ON_WM_RBUTTONDOWN()
ON_WM_KEYDOWN()
ON_WM_SYSKEYDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSaverWnd message handlers
BOOL CSaverWnd::Create()
{
CRect rect(0, 0, ::GetSystemMetrics(SM_CXSCREEN),
::GetSystemMetrics(SM_CYSCREEN));
return CDrawWnd::Create(WS_EX_TOPMOST, WS_VISIBLE|WS_POPUP, rect, NULL,
0, NULL);
}
void CSaverWnd::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID == SC_SCREENSAVE) || (nID == SC_CLOSE))
return;
CDrawWnd::OnSysCommand(nID, lParam);
}
void CSaverWnd::OnDestroy()
{
PostQuitMessage(0);
CDrawWnd::OnDestroy();
}
BOOL CSaverWnd::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
SetCursor(NULL);
return TRUE;
}
BOOL CSaverWnd::OnNcActivate(BOOL bActive)
{
if (!bActive)
return FALSE;
return CDrawWnd::OnNcActivate(bActive);
}
void CSaverWnd::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{
if (nState == WA_INACTIVE)
PostMessage(WM_CLOSE);
CDrawWnd::OnActivate(nState, pWndOther, bMinimized);
}
void CSaverWnd::OnActivateApp(BOOL bActive, HTASK hTask)
{
if (!bActive)
PostMessage(WM_CLOSE);
CDrawWnd::OnActivateApp(bActive, hTask);
}
void CSaverWnd::OnMouseMove(UINT nFlags, CPoint point)
{
if (m_ptLast == CPoint(-1,-1))
m_ptLast = point;
else if (m_ptLast != point)
PostMessage(WM_CLOSE);
CDrawWnd::OnMouseMove(nFlags, point);
}
void CSaverWnd::OnLButtonDown(UINT nFlags, CPoint point)
{
PostMessage(WM_CLOSE);
CDrawWnd::OnLButtonDown(nFlags, point);
}
void CSaverWnd::OnMButtonDown(UINT nFlags, CPoint point)
{
PostMessage(WM_CLOSE);
CDrawWnd::OnMButtonDown(nFlags, point);
}
void CSaverWnd::OnRButtonDown(UINT nFlags, CPoint point)
{
PostMessage(WM_CLOSE);
CDrawWnd::OnRButtonDown(nFlags, point);
}
void CSaverWnd::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
PostMessage(WM_CLOSE);
CDrawWnd::OnKeyDown(nChar, nRepCnt, nFlags);
}
void CSaverWnd::OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
PostMessage(WM_CLOSE);
CDrawWnd::OnSysKeyDown(nChar, nRepCnt, nFlags);
}