-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainFrm.cpp
218 lines (187 loc) · 5.31 KB
/
MainFrm.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
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
// MainFrm.cpp : CMainFrame 类的实现
//
#include "stdafx.h"
#include "SaleSystem.h"
#include "MainFrm.h"
#include "SelectView.h"
#include "DisplayView.h"
#include "DlgPerson1.h"
#include "DlgSell.h"
#include "DlgInfo.h"
#include "DlgAdd.h"
#include "DlgDel.h"
#include "DlgSearch.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CMainFrame
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
//消息映射入口定义
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
ON_WM_CREATE()
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)
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // 状态行指示器
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
// CMainFrame 构造/析构
CMainFrame::CMainFrame()
{
// 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));
//加载图标
//GetClassLong(m_hWnd, (LONG)AfxGetApp()->LoadIcon(IDI_ICON1));
SetClassLong(m_hWnd,GCL_HICON, (LONG)AfxGetApp()->LoadIcon(IDI_ICON2));
//设置窗口显示位置和大小
MoveWindow(100, 50, 900, 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: 在此添加专用代码和/或调用基类
//return CFrameWnd::OnCreateClient(lpcs, pContext);
//静态拆分
m_splitter.CreateStatic(this, 1, 2);
//拆分窗口
m_splitter.CreateView(0, 0, RUNTIME_CLASS(CSelectView), CSize(240, 600),pContext);
m_splitter.CreateView(0, 1, RUNTIME_CLASS(CDisplayView), CSize(660, 600), pContext);
return TRUE;
}
//自定义映射消息函数功能实现
LRESULT CMainFrame::OnMyChange(WPARAM wparam, LPARAM lparam)
{
CCreateContext Context;
switch (wparam)
{
case NM_A:
{
//CUserDlg类需要包含头文件#include "UserDlg.h"
Context.m_pNewViewClass = RUNTIME_CLASS(CDlgPerson1);
Context.m_pCurrentFrame = this;
Context.m_pLastView = (CFormView *)m_splitter.GetPane(0, 1);
m_splitter.DeleteView(0, 1);
m_splitter.CreateView(0, 1, RUNTIME_CLASS(CDlgPerson1), CSize(600, 0), &Context);
CDlgPerson1 *pNewView = (CDlgPerson1 *)m_splitter.GetPane(0, 1);
m_splitter.RecalcLayout();
pNewView->OnInitialUpdate();
m_splitter.SetActivePane(0, 1);
}
break;
case NM_B:
{
//CUserDlg类需要包含头文件#include "UserDlg.h"
Context.m_pNewViewClass = RUNTIME_CLASS(CDlgSell);
Context.m_pCurrentFrame = this;
Context.m_pLastView = (CFormView *)m_splitter.GetPane(0, 1);
m_splitter.DeleteView(0, 1);
m_splitter.CreateView(0, 1, RUNTIME_CLASS(CDlgSell), CSize(600, 0), &Context);
CDlgSell *pNewView = (CDlgSell *)m_splitter.GetPane(0, 1);
m_splitter.RecalcLayout();
pNewView->OnInitialUpdate();
m_splitter.SetActivePane(0, 1);
}
break;
case NM_C:
{
//CUserDlg类需要包含头文件#include "UserDlg.h"
Context.m_pNewViewClass = RUNTIME_CLASS(CDlgInfo);
Context.m_pCurrentFrame = this;
Context.m_pLastView = (CFormView *)m_splitter.GetPane(0, 1);
m_splitter.DeleteView(0, 1);
m_splitter.CreateView(0, 1, RUNTIME_CLASS(CDlgInfo), CSize(600, 0), &Context);
CDlgInfo *pNewView = (CDlgInfo *)m_splitter.GetPane(0, 1);
m_splitter.RecalcLayout();
pNewView->OnInitialUpdate();
m_splitter.SetActivePane(0, 1);
}
break;
case NM_D:
{
//CUserDlg类需要包含头文件#include "UserDlg.h"
Context.m_pNewViewClass = RUNTIME_CLASS(CDlgAdd);
Context.m_pCurrentFrame = this;
Context.m_pLastView = (CFormView *)m_splitter.GetPane(0, 1);
m_splitter.DeleteView(0, 1);
m_splitter.CreateView(0, 1, RUNTIME_CLASS(CDlgAdd), CSize(600, 0), &Context);
CDlgAdd *pNewView = (CDlgAdd *)m_splitter.GetPane(0, 1);
m_splitter.RecalcLayout();
pNewView->OnInitialUpdate();
m_splitter.SetActivePane(0, 1);
}
break;
case NM_E:
{
//CUserDlg类需要包含头文件#include "UserDlg.h"
Context.m_pNewViewClass = RUNTIME_CLASS(CDlgDel);
Context.m_pCurrentFrame = this;
Context.m_pLastView = (CFormView *)m_splitter.GetPane(0, 1);
m_splitter.DeleteView(0, 1);
m_splitter.CreateView(0, 1, RUNTIME_CLASS(CDlgDel), CSize(600, 0), &Context);
CDlgDel *pNewView = (CDlgDel *)m_splitter.GetPane(0, 1);
m_splitter.RecalcLayout();
pNewView->OnInitialUpdate();
m_splitter.SetActivePane(0, 1);
}
break;
case NM_F:
{
//CUserDlg类需要包含头文件#include "UserDlg.h"
Context.m_pNewViewClass = RUNTIME_CLASS(CDlgSearch);
Context.m_pCurrentFrame = this;
Context.m_pLastView = (CFormView *)m_splitter.GetPane(0, 1);
m_splitter.DeleteView(0, 1);
m_splitter.CreateView(0, 1, RUNTIME_CLASS(CDlgSearch), CSize(600, 0), &Context);
CDlgSearch *pNewView = (CDlgSearch *)m_splitter.GetPane(0, 1);
m_splitter.RecalcLayout();
pNewView->OnInitialUpdate();
m_splitter.SetActivePane(0, 1);
}
break;
default:
break;
}
return 0;
}