-
Notifications
You must be signed in to change notification settings - Fork 2
/
BackupSetView.cpp
136 lines (100 loc) · 2.69 KB
/
BackupSetView.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
// BackupSetView.cpp : 实现文件
//
#include "stdafx.h"
#include "BCGPChartExample.h"
#include "BackupSetView.h"
#include "afxdialogex.h"
// CBackupSetView 对话框
IMPLEMENT_DYNAMIC(CBackupSetView, CDialogEx)
CBackupSetView::CBackupSetView(CWnd* pParent /*=NULL*/)
: CDialogEx(CBackupSetView::IDD, pParent)
{
}
CBackupSetView::~CBackupSetView()
{
}
void CBackupSetView::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CBackupSetView, CDialogEx)
ON_WM_CLOSE()
ON_WM_CTLCOLOR()
ON_WM_PAINT()
ON_WM_SIZE()
END_MESSAGE_MAP()
// CBackupSetView 消息处理程序
BOOL CBackupSetView::OnInitDialog()
{
CDialogEx::OnInitDialog();
// TODO: 在此添加额外的初始化
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
HBRUSH CBackupSetView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: 在此更改 DC 的任何特性
switch (pWnd->GetDlgCtrlID())
{
case IDC_STATIC0:
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(0, 0, 0));
return (HBRUSH)GetStockObject(HOLLOW_BRUSH);
default:
break;
}
// TODO: 如果默认的不是所需画笔,则返回另一个画笔
return hbr;
}
void CBackupSetView::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: 在此处添加消息处理程序代码
// 不为绘图消息调用 CDialogEx::OnPaint()
CRect rect;
GetClientRect(rect);
dc.FillSolidRect(rect, RGB(255, 255, 255));
dc.FillPath();
}
void CBackupSetView::OnSize(UINT nType, int cx, int cy)
{
CDialogEx::OnSize(nType, cx, cy);
// TODO: 在此处添加消息处理程序代码
if (nType == 1) return;//最小化则什么都不做
// TODO: Add your message handler code here
CWnd *pWnd;
pWnd = GetDlgItem(IDC_BUTTON1);
ChangeSize(pWnd, cx, cy);
GetClientRect(&m_rect);// 将变化后的对话框大小设为旧大小
}
void CBackupSetView::OnCancel()
{
// TODO: 在此添加专用代码和/或调用基类
CDialogEx::OnCancel();
}
void CBackupSetView::OnOK()
{
// TODO: 在此添加专用代码和/或调用基类
CDialogEx::OnOK();
}
void CBackupSetView::OnClose()
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
CDialogEx::OnClose();
}
void CBackupSetView::ChangeSize(CWnd *pWnd, int cx, int cy)
{
if (pWnd) //判断是否为空,因为对话框创建时会调用此函数,而当时控件还未创建
{
CRect rect; //获取控件变化前的大小
pWnd->GetWindowRect(&rect);
ScreenToClient(&rect);//将控件大小转换为在对话框中的区域坐标
// cx/m_rect.Width()为对话框在横向的变化比例
rect.left = rect.left*cx / m_rect.Width();//调整控件大小
rect.right = rect.right*cx / m_rect.Width();
rect.top = rect.top*cy / m_rect.Height();
rect.bottom = rect.bottom*cy / m_rect.Height();
pWnd->MoveWindow(rect);//设置控件大小
}
}