提交 | 用户 | age
|
61deef
|
1 |
|
Q |
2 |
// ChildFrm.cpp: CChildFrame 类的实现
|
|
3 |
//
|
|
4 |
|
|
5 |
#include "pch.h"
|
|
6 |
#include "framework.h"
|
|
7 |
#include "MFCApplication1.h"
|
|
8 |
|
|
9 |
#include "ChildFrm.h"
|
|
10 |
|
|
11 |
#ifdef _DEBUG
|
|
12 |
#define new DEBUG_NEW
|
|
13 |
#endif
|
|
14 |
|
|
15 |
// CChildFrame
|
|
16 |
|
|
17 |
IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd)
|
|
18 |
|
|
19 |
BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)
|
|
20 |
ON_COMMAND(ID_FILE_CLOSE, &CChildFrame::OnFileClose)
|
|
21 |
ON_WM_SETFOCUS()
|
|
22 |
ON_WM_CREATE()
|
|
23 |
END_MESSAGE_MAP()
|
|
24 |
|
|
25 |
// CChildFrame 构造/析构
|
|
26 |
|
|
27 |
CChildFrame::CChildFrame() noexcept
|
|
28 |
{
|
|
29 |
// TODO: 在此添加成员初始化代码
|
|
30 |
}
|
|
31 |
|
|
32 |
CChildFrame::~CChildFrame()
|
|
33 |
{
|
|
34 |
}
|
|
35 |
|
|
36 |
|
|
37 |
BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
|
|
38 |
{
|
|
39 |
// TODO: 在此处通过修改 CREATESTRUCT cs 来修改窗口类或样式
|
|
40 |
if( !CMDIChildWnd::PreCreateWindow(cs) )
|
|
41 |
return FALSE;
|
|
42 |
|
|
43 |
cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
|
|
44 |
cs.lpszClass = AfxRegisterWndClass(0);
|
|
45 |
return TRUE;
|
|
46 |
}
|
|
47 |
|
|
48 |
// CChildFrame 诊断
|
|
49 |
|
|
50 |
#ifdef _DEBUG
|
|
51 |
void CChildFrame::AssertValid() const
|
|
52 |
{
|
|
53 |
CMDIChildWnd::AssertValid();
|
|
54 |
}
|
|
55 |
|
|
56 |
void CChildFrame::Dump(CDumpContext& dc) const
|
|
57 |
{
|
|
58 |
CMDIChildWnd::Dump(dc);
|
|
59 |
}
|
|
60 |
#endif //_DEBUG
|
|
61 |
|
|
62 |
// CChildFrame 消息处理程序
|
|
63 |
void CChildFrame::OnFileClose()
|
|
64 |
{
|
|
65 |
// 若要关闭框架,只需发送 WM_CLOSE,
|
|
66 |
// 这相当于从系统菜单中选择关闭。
|
|
67 |
SendMessage(WM_CLOSE);
|
|
68 |
}
|
|
69 |
|
|
70 |
int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
|
71 |
{
|
|
72 |
if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
|
|
73 |
return -1;
|
|
74 |
|
|
75 |
// 创建一个视图以占用框架的工作区
|
|
76 |
if (!m_wndView.Create(nullptr, nullptr, AFX_WS_DEFAULT_VIEW,
|
|
77 |
CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, nullptr))
|
|
78 |
{
|
|
79 |
TRACE0("未能创建视图窗口\n");
|
|
80 |
return -1;
|
|
81 |
}
|
|
82 |
|
|
83 |
return 0;
|
|
84 |
}
|
|
85 |
|
|
86 |
void CChildFrame::OnSetFocus(CWnd* pOldWnd)
|
|
87 |
{
|
|
88 |
CMDIChildWnd::OnSetFocus(pOldWnd);
|
|
89 |
|
|
90 |
m_wndView.SetFocus();
|
|
91 |
}
|
|
92 |
|
|
93 |
BOOL CChildFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
|
|
94 |
{
|
|
95 |
// 让视图第一次尝试该命令
|
|
96 |
if (m_wndView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
|
|
97 |
return TRUE;
|
|
98 |
|
|
99 |
// 否则,执行默认处理
|
|
100 |
return CMDIChildWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
|
|
101 |
}
|