📄 mdidialog.cpp
字号:
// MDIDialog.cpp : implementation file
//
#include "stdafx.h"
//#include "Unp70.h"
#include "MDIDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
////////////////////////////////////////////////////////////////////////////
//
// CMDIDialog dialog
CMDIDialog::CMDIDialog(LPCTSTR lpszTemplateName, CWnd* pParent) : CDialog(lpszTemplateName, pParent)
{
bInserted = false;
}
CMDIDialog::CMDIDialog(UINT nIDTemplate, CWnd* pParent) : CDialog(nIDTemplate, pParent)
{
bInserted = false;
}
BEGIN_MESSAGE_MAP(CMDIDialog, CDialog)
//{{AFX_MSG_MAP(CMDIDialog)
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
////////////////////////////////////////////////////////////////////////////
//
// CMDIDialog message handlers
void CMDIDialog::OnCancel()
{
if ( bInserted )
DestroyWindow();
else
CDialog::OnCancel();
}
void CMDIDialog::OnOK()
{
if ( bInserted )
DestroyWindow();
else
CDialog::OnOK();
}
void CMDIDialog::OnDestroy()
{
CDialog::OnDestroy();
if ( bInserted )
delete(this);
}
void CMDIDialog::DoInsert()
{
CMDIFrameWnd* pWnd = (CMDIFrameWnd*) AfxGetMainWnd();
CWnd* pChildWnd = FromHandle(pWnd -> m_hWndMDIClient);
bInserted = true;
Create(m_lpszTemplateName, NULL);
SetParent(pChildWnd);
if ( GetStyle() & DS_CENTER )
CenterWindow();
SetFocus();
ShowWindow(SW_SHOW);
}
void CMDIDialog::CenterWindow(CWnd* pAlternateOwner)
{
CWnd* pWnd = AfxGetMainWnd();
CRect Rect;
int nX, nY;
if ( bInserted )
if ( pAlternateOwner != NULL )
CDialog::CenterWindow(pAlternateOwner);
else
{
pWnd = AfxGetMainWnd();
pWnd -> GetClientRect(&Rect);
nX = Rect.Width() / 2;
nY = Rect.Height() / 2;
GetWindowRect(&Rect);
nX -= Rect.Width() / 2;
if ( nX < 0 ) nX = 0;
nY -= Rect.Height() / 2;
if ( nY < 0 ) nY = 0;
SetWindowPos(NULL, nX, nY, 0, 0, SWP_NOSIZE);
}
else
CDialog::CenterWindow(pAlternateOwner);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -