ekfixedformframe.cpp

来自「《MFC经典问答》pdf格式 拿出来大家共享一下」· C++ 代码 · 共 86 行

CPP
86
字号
// EkFixedFormFrame.cpp : implementation file
//

#include "stdafx.h"

#include "EkFixedFormFrame.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CEkFixedFormFrame

IMPLEMENT_DYNCREATE(CEkFixedFormFrame, CMDIChildWnd)

CEkFixedFormFrame::CEkFixedFormFrame()
{
}

CEkFixedFormFrame::~CEkFixedFormFrame()
{
}


BEGIN_MESSAGE_MAP(CEkFixedFormFrame, CMDIChildWnd)
	//{{AFX_MSG_MAP(CEkFixedFormFrame)
	ON_WM_CREATE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CEkFixedFormFrame message handlers

BOOL CEkFixedFormFrame::PreCreateWindow(CREATESTRUCT& cs) 
{
	// Make the frame window non-resizable
	cs.style &= ~WS_THICKFRAME;
	cs.style &= ~WS_MAXIMIZEBOX;

	return CMDIChildWnd::PreCreateWindow(cs);
}

int CEkFixedFormFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// The child FormView should already have been created
	// by the call to CMDIChildWnd::OnCreate()
	CFormView* pFormView = static_cast< CFormView* >
								( GetDescendantWindow( AFX_IDW_PANE_FIRST, TRUE ) );
	ASSERT_VALID( pFormView );
	ASSERT_KINDOF( CFormView, pFormView );

	// Make sure that the view window size is correctly set
	RecalcLayout();

	// Make the view resize its parent frame -- that is
	// "us", normally !
	pFormView->ResizeParentToFit( FALSE );
	pFormView->ResizeParentToFit( TRUE );

	return 0;
}

void CEkFixedFormFrame::OnUpdateFrameTitle( BOOL bAddToTitle )
{
	// 1 - First call default function
	CMDIChildWnd::OnUpdateFrameTitle( bAddToTitle );

	// 2 - Now adapt the title to our taste

	// 2a - Get the document title
	CDocument* pDoc = GetActiveDocument();
	if( pDoc );
	{
		CString strDocTitle = pDoc->GetTitle();

		// 2b - Build our custom frame title
		CString strMyTitle = "Form - " + strDocTitle;
		SetWindowText( strMyTitle );
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?