📄 ngmdiframewnd.cpp
字号:
// NGMDIFrameWnd.cpp : implementation of the CNGMDIFrameWnd class
//
#include "stdafx.h"
#include "NGUtils.h"
#include "NGMDIFrameWnd.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CNGMDIFrameWnd
IMPLEMENT_DYNCREATE(CNGMDIFrameWnd, CNGMDIFrameWnd_BASE)
BEGIN_MESSAGE_MAP(CNGMDIFrameWnd, CNGMDIFrameWnd_BASE)
//{{AFX_MSG_MAP(CNGMDIFrameWnd)
ON_WM_CREATE()
ON_WM_SHOWWINDOW()
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
/////////////////////////////////////////////////////////////////////////////
// CNGMDIFrameWnd construction/destruction
CNGMDIFrameWnd::CNGMDIFrameWnd(void)
{
m_sCtrlBarProfileName = _T("");
m_bInitialShow = FALSE;
}
CNGMDIFrameWnd::~CNGMDIFrameWnd(void)
{
}
/******************************************************************************
* Called by the framework before the window is created
*
******************************************************************************/
BOOL CNGMDIFrameWnd::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CNGMDIFrameWnd_BASE::PreCreateWindow(cs);
}
/******************************************************************************
* Called by the framework when the window is created
*
******************************************************************************/
int CNGMDIFrameWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
int nResult = CNGMDIFrameWnd_BASE::OnCreate(lpCreateStruct);
if (nResult != -1)
{
}
return nResult;
}
/******************************************************************************
* Called by the app to show the main window
*
******************************************************************************/
void CNGMDIFrameWnd::InitialShowWindow(UINT nCmdShow)
{
m_bInitialShow = true;
if (!m_sCtrlBarProfileName.IsEmpty())
{
LoadBarState(m_sCtrlBarProfileName);
}
WINDOWPLACEMENT wp;
if (!::ReadWindowPlacement(&wp))
{
ShowWindow(nCmdShow);
return;
}
if (nCmdShow != SW_SHOWNORMAL)
{
wp.showCmd = nCmdShow;
}
SetWindowPlacement(&wp);
CMDIChildWnd* pChild = MDIGetActive();
if (NULL != pChild)
{
MDIMaximize(pChild);
}
}
/******************************************************************************
* Called by the framework when a child window is created
*
******************************************************************************/
BOOL CNGMDIFrameWnd::OnCreateClient( LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
BOOL bResult = CNGMDIFrameWnd_BASE::OnCreateClient(lpcs, pContext);
return bResult;
}
/////////////////////////////////////////////////////////////////////////////
// CNGMDIFrameWnd operations
/******************************************************************************
* Opens a new view on the given document
*
* The view type depends on the given document template
*
******************************************************************************/
void CNGMDIFrameWnd::CreateView(CDocument* pDoc, CDocTemplate* pTemplate)
{
ASSERT_VALID(pTemplate);
if (NULL == pDoc)
{
TRACE0("Warning: No active document for WindowNew command.\n");
AfxMessageBox(AFX_IDP_COMMAND_FAILURE, MB_OK | MB_ICONSTOP);
return; // command failed
}
CFrameWnd* pFrame = pTemplate->CreateNewFrame(pDoc, NULL);
if (pFrame == NULL)
{
TRACE0("Warning: failed to create new frame.\n");
AfxMessageBox(AFX_IDP_COMMAND_FAILURE, MB_OK | MB_ICONSTOP);
return; // command failed
}
pTemplate->InitialUpdateFrame(pFrame, pDoc);
}
/////////////////////////////////////////////////////////////////////////////
// CNGMDIFrameWnd diagnostics
#ifdef _DEBUG
void CNGMDIFrameWnd::AssertValid(void) const
{
CNGMDIFrameWnd_BASE::AssertValid();
}
void CNGMDIFrameWnd::Dump(CDumpContext& dc) const
{
CNGMDIFrameWnd_BASE::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CNGMDIFrameWnd message handlers
/******************************************************************************
* The framework calls this member function when the window
* is shown or hidden.
*
* This override determines if the window is being shown for the first time,
* and, if so, calls InitialShowWindow() to load the window size/position
* from the registry.
*
******************************************************************************/
void CNGMDIFrameWnd::OnShowWindow(BOOL bShow, UINT nStatus)
{
CNGMDIFrameWnd_BASE::OnShowWindow(bShow, nStatus);
if (bShow && (nStatus == 0) && !m_bInitialShow)
{
InitialShowWindow(SW_SHOWNORMAL);
}
}
/******************************************************************************
* The framework calls this member function as a signal that the window
* should be closed
*
* This override saves the state of all docking windows, and the
* size/position of the main window before exiting
*
******************************************************************************/
void CNGMDIFrameWnd::OnClose(void)
{
ASSERT(::IsWindow(m_hWnd));
if (!m_sCtrlBarProfileName.IsEmpty())
{
SaveBarState(m_sCtrlBarProfileName);
}
// Before it is destroyed, save the position of the window
WINDOWPLACEMENT wp;
wp.length = sizeof wp;
if (GetWindowPlacement(&wp))
{
wp.flags = 0;
if (IsZoomed())
{
wp.flags |= WPF_RESTORETOMAXIMIZED;
}
// ...and write it to the registry
::WriteWindowPlacement(&wp);
}
CNGMDIFrameWnd_BASE::OnClose();
}
/////////////////////////////////////////////////////////////////////////////
// CNGMDIFrameWnd implementation
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -