stdafx.cpp

来自「Visual C++高级编程及其项目应用开发(含源代码)」· C++ 代码 · 共 58 行

CPP
58
字号
// stdafx.cpp : source file that includes just the standard includes
//	clientMain.pch will be the pre-compiled header
//	stdafx.obj will contain the pre-compiled type information

#include "stdafx.h"
#include <string>


CFrameWnd* EkCreateNewWindow( CDocTemplate* pTemplate,
                              CDocument* pDocument )
{
	ASSERT_VALID( pTemplate );
	ASSERT_VALID( pDocument );

	// 1 - Create the new frame window
	// (will in turn create the associated view)
	CFrameWnd* pFrame = pTemplate->CreateNewFrame(
										pDocument, NULL );

	if( pFrame == NULL )
	{
		// Window creation failed
		TRACE0( "Warning: failed to create new frame.\n" );
		return NULL;
	}
	ASSERT_KINDOF( CFrameWnd, pFrame );

	// 2 - Tell the frame to update itself
	// (and its child windows)
	pTemplate->InitialUpdateFrame( pFrame, pDocument );

	// 3 - Return a pointer to the new frame window object
	return pFrame;
}

CDocument* EkGetActiveDocument()
{
	// 1 - Get a pointer to the application's
	// main frame window
	CWnd* pWnd = AfxGetMainWnd();
	if( pWnd == NULL )
		return NULL;

	// 2 - Make sure the pointer is valid and more
	// strongly typed
	ASSERT_VALID( pWnd );
	ASSERT_KINDOF( CFrameWnd, pWnd );
	CFrameWnd* pMainFrame = static_cast< CFrameWnd* >( pWnd );

	// 3 - Get a pointer to the active frame window
	// (may be 'this' for SDI application)
	CFrameWnd* pActiveFrame = pMainFrame->GetActiveFrame();
	if( pActiveFrame == NULL )
		return NULL;

	// 4 - Return a pointer to the active document object
	return pActiveFrame->GetActiveDocument();
}

⌨️ 快捷键说明

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