-
Notifications
You must be signed in to change notification settings - Fork 149
/
DoubleBuffer.h
54 lines (42 loc) · 913 Bytes
/
DoubleBuffer.h
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
#pragma once
//#include <atltypes.h>
//#include <atlcrack.h>
#define MSG_WM_PAINT_Window(func) \
if (uMsg == WM_PAINT) \
{ \
SetMsgHandled(TRUE); \
func(hWnd,(HDC)wParam); \
lResult = 0; \
if(IsMsgHandled()) \
return TRUE; \
}
class CDoubleBuffer
{
public:
BEGIN_MSG_MAP_EX(CDoubleBuffer)
MSG_WM_ERASEBKGND(OnEraseBkgnd)
MSG_WM_PAINT_Window(OnPaint)
END_MSG_MAP()
BOOL OnEraseBkgnd(CDCHandle dc)
{
return TRUE;
}
void OnPaint(CWindow hWnd, HDC dc)
{
if (dc)
{
RECT rect;
hWnd.GetClientRect(&rect);
CMemoryDC dcMem(dc, rect);
dcMem.FillSolidRect(&rect, GetSysColor(COLOR_WINDOW));
DefWindowProc(hWnd, WM_PAINT, (WPARAM)dcMem.m_hDC, 0);
}
else
{
CPaintDC dc(hWnd);
CMemoryDC dcMem(dc.m_hDC, dc.m_ps.rcPaint);
dcMem.FillSolidRect(&dc.m_ps.rcPaint, GetSysColor(COLOR_WINDOW));
DefWindowProc(hWnd, WM_PAINT, (WPARAM)dcMem.m_hDC, 0);
}
}
};