nocloseframe.cpp
来自「《MFC经典问答》pdf格式 拿出来大家共享一下」· C++ 代码 · 共 56 行
CPP
56 行
// NoCloseFrame.cpp : implementation file
//
#include "stdafx.h"
#include "dontcloseview.h"
#include "NoCloseFrame.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CNoCloseFrame
IMPLEMENT_DYNCREATE(CNoCloseFrame, CMDIChildWnd)
CNoCloseFrame::CNoCloseFrame()
{
}
CNoCloseFrame::~CNoCloseFrame()
{
}
BEGIN_MESSAGE_MAP(CNoCloseFrame, CMDIChildWnd)
//{{AFX_MSG_MAP(CNoCloseFrame)
ON_COMMAND(ID_CLOSE_FRAME, OnCloseFrame)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CNoCloseFrame message handlers
BOOL CNoCloseFrame::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext)
{
// 1 - Call base class function
BOOL bRet = CMDIChildWnd::LoadFrame(nIDResource, dwDefaultStyle, pParentWnd, pContext);
if( bRet )
{
// 2 - Disable the "Close" command in the System menu
CMenu* pMenu = GetSystemMenu( FALSE );
pMenu->EnableMenuItem( SC_CLOSE, MF_BYCOMMAND | MF_GRAYED );
}
return bRet;
}
void CNoCloseFrame::OnCloseFrame()
{
PostMessage( WM_CLOSE );
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?