-
Notifications
You must be signed in to change notification settings - Fork 52
/
PreviewWnd.cpp
58 lines (51 loc) · 1.11 KB
/
PreviewWnd.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
// PreviewWnd.cpp : ʵÏÖÎļþ
#include "stdafx.h"
#include "FontMakerApp.h"
#include "PreviewWnd.h"
// CPreviewWnd
IMPLEMENT_DYNAMIC(CPreviewWnd, CWnd)
BEGIN_MESSAGE_MAP(CPreviewWnd, CWnd)
ON_WM_PAINT()
ON_WM_DESTROY()
END_MESSAGE_MAP()
void CPreviewWnd::SetDC(HDC hdc)
{
m_dc.Attach(hdc);
}
void CPreviewWnd::SetSize(INT width, INT height)
{
RECT rc;
GetClientRect(&rc);
m_nWidth = width;
m_nHeight = height;
m_nPaintX = (rc.right-m_nWidth)/2;
m_nPaintY = (rc.bottom-m_nHeight)/2;
}
// CPreviewWnd ÏûÏ¢´¦Àí³ÌÐò
void CPreviewWnd::OnPaint()
{
CBrush br;
CRgn rgn;
CPaintDC dc(this);
rgn.CreateRectRgnIndirect(&m_client);
br.CreateSysColorBrush(COLOR_BTNFACE);
dc.SelectClipRgn(&rgn);
dc.FillRect(&m_client,&br);
dc.BitBlt(m_nPaintX,m_nPaintY,m_nWidth,m_nHeight,&m_dc,0,0,SRCCOPY);
br.DeleteObject();
rgn.DeleteObject();
}
void CPreviewWnd::PreSubclassWindow()
{
m_nWidth = 0;
m_nHeight = 0;
m_nPaintX = 0;
m_nPaintY = 0;
GetClientRect(&m_client);
CWnd::PreSubclassWindow();
}
void CPreviewWnd::OnDestroy()
{
CWnd::OnDestroy();
m_dc.Detach();
}