-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainFrm.cpp
More file actions
230 lines (195 loc) · 5.64 KB
/
MainFrm.cpp
File metadata and controls
230 lines (195 loc) · 5.64 KB
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
// MainFrm.cpp: CMainFrame 类的实现
//
#include "pch.h"
#include "framework.h"
#include "WorkerManager.h"
#include "MainFrm.h"
#include "CDisplayView.h"
#include "CSelectView.h"
#include "WelcomeDlg.h"
#include "AddWorker.h"
#include "ListWorker.h"
#include "ChangeWorker.h"
#include "DeleteWorker.h"
#include "FindWorker.h"
#include "Wage.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CMainFrame
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
ON_WM_CREATE()
//ON_MESSAGE响应的是自定义消息
//产生NM_X消息,自动调用OnMyChange函数
ON_MESSAGE(NM_A, OnMyChange)
ON_MESSAGE(NM_B, OnMyChange)
ON_MESSAGE(NM_C, OnMyChange)
ON_MESSAGE(NM_D, OnMyChange)
ON_MESSAGE(NM_E, OnMyChange)
ON_MESSAGE(NM_F, OnMyChange)
ON_MESSAGE(NM_G, OnMyChange)
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // 状态行指示器
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
// CMainFrame 构造/析构
CMainFrame::CMainFrame() noexcept
{
// TODO: 在此添加成员初始化代码
}
CMainFrame::~CMainFrame()
{
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndStatusBar.Create(this))
{
TRACE0("未能创建状态栏\n");
return -1; // 未能创建
}
m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT));
//设置窗口位置和大小(起点坐标x,y,窗口宽度,高度)
MoveWindow(0, 0, 800, 600);
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: 在此处通过修改
// CREATESTRUCT cs 来修改窗口类或样式
return TRUE;
}
// CMainFrame 诊断
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}
#endif //_DEBUG
// CMainFrame 消息处理程序
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: 在此添加专用代码和/或调用基类
//静态拆分窗口,1行2列
m_spliter.CreateStatic(this, 1, 2);
//创建视图,第0行,第0列
//CSize()宽度200,高度500
m_spliter.CreateView(0, 0, RUNTIME_CLASS(CSelectView), CSize(200, 500), pContext);
m_spliter.CreateView(0, 1, RUNTIME_CLASS(CDisplayView), CSize(600, 500), pContext);
//return CFrameWnd::OnCreateClient(lpcs, pContext);
return TRUE;
}
LRESULT CMainFrame::OnMyChange(WPARAM wParam, LPARAM lParam)
{
CCreateContext Context;
switch (wParam)
{
case NM_A:
{
Context.m_pNewViewClass = RUNTIME_CLASS(WelcomeDlg);
Context.m_pCurrentFrame = this;
Context.m_pLastView = (CFormView*)m_spliter.GetPane(0, 1);
m_spliter.DeleteView(0, 1);
m_spliter.CreateView(0, 1, RUNTIME_CLASS(WelcomeDlg), CSize(600, 0), &Context);
WelcomeDlg* pNewView = (WelcomeDlg*)m_spliter.GetPane(0, 1);
m_spliter.RecalcLayout();
pNewView->OnInitialUpdate();
m_spliter.SetActivePane(0, 1);
}
break;
case NM_B:
{
Context.m_pNewViewClass = RUNTIME_CLASS(AddWorker);
Context.m_pCurrentFrame = this;
Context.m_pLastView = (CFormView*)m_spliter.GetPane(0, 1);
m_spliter.DeleteView(0, 1);
m_spliter.CreateView(0, 1, RUNTIME_CLASS(AddWorker), CSize(600, 500), &Context);
AddWorker* pNewView = (AddWorker*)m_spliter.GetPane(0, 1);
m_spliter.RecalcLayout();
pNewView->OnInitialUpdate();
m_spliter.SetActivePane(0, 1);
}
break;
case NM_C:
{
Context.m_pNewViewClass = RUNTIME_CLASS(ListWorker);
Context.m_pCurrentFrame = this;
Context.m_pLastView = (CFormView*)m_spliter.GetPane(0, 1);
m_spliter.DeleteView(0, 1);
m_spliter.CreateView(0, 1, RUNTIME_CLASS(ListWorker), CSize(600, 500), &Context);
ListWorker* pNewView = (ListWorker*)m_spliter.GetPane(0, 1);
m_spliter.RecalcLayout();
pNewView->OnInitialUpdate();
m_spliter.SetActivePane(0, 1);
}
break;
case NM_D:
{
Context.m_pNewViewClass = RUNTIME_CLASS(ChangeWorker);
Context.m_pCurrentFrame = this;
Context.m_pLastView = (CFormView*)m_spliter.GetPane(0, 1);
m_spliter.DeleteView(0, 1);
m_spliter.CreateView(0, 1, RUNTIME_CLASS(ChangeWorker), CSize(600, 500), &Context);
ChangeWorker* pNewView = (ChangeWorker*)m_spliter.GetPane(0, 1);
m_spliter.RecalcLayout();
pNewView->OnInitialUpdate();
m_spliter.SetActivePane(0, 1);
}
break;
case NM_E:
{
Context.m_pNewViewClass = RUNTIME_CLASS(DeleteWorker);
Context.m_pCurrentFrame = this;
Context.m_pLastView = (CFormView*)m_spliter.GetPane(0, 1);
m_spliter.DeleteView(0, 1);
m_spliter.CreateView(0, 1, RUNTIME_CLASS(DeleteWorker), CSize(600, 500), &Context);
DeleteWorker* pNewView = (DeleteWorker*)m_spliter.GetPane(0, 1);
m_spliter.RecalcLayout();
pNewView->OnInitialUpdate();
m_spliter.SetActivePane(0, 1);
}
break;
case NM_F:
{
Context.m_pNewViewClass = RUNTIME_CLASS(FindWorker);
Context.m_pCurrentFrame = this;
Context.m_pLastView = (CFormView*)m_spliter.GetPane(0, 1);
m_spliter.DeleteView(0, 1);
m_spliter.CreateView(0, 1, RUNTIME_CLASS(FindWorker), CSize(600, 500), &Context);
FindWorker* pNewView = (FindWorker*)m_spliter.GetPane(0, 1);
m_spliter.RecalcLayout();
pNewView->OnInitialUpdate();
m_spliter.SetActivePane(0, 1);
}
break;
case NM_G:
{
Context.m_pNewViewClass = RUNTIME_CLASS(Wage);
Context.m_pCurrentFrame = this;
Context.m_pLastView = (CFormView*)m_spliter.GetPane(0, 1);
m_spliter.DeleteView(0, 1);
m_spliter.CreateView(0, 1, RUNTIME_CLASS(Wage), CSize(600, 500), &Context);
Wage* pNewView = (Wage*)m_spliter.GetPane(0, 1);
m_spliter.RecalcLayout();
pNewView->OnInitialUpdate();
m_spliter.SetActivePane(0, 1);
}
break;
default:
MessageBox(_T("error"));
}
return 0;
}