⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainfrm.cpp

📁 VC源代码大全(精华版)
💻 CPP
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//

#include "stdafx.h"
#include "Split.h"
#include	"SplitDoc.h"
#include	"FirstView.h"

#include "MainFrm.h"

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

// #define FOUR_PANEL_TEST

/////////////////////////////////////////////////////////////////////////////
// CMainFrame

IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
	//{{AFX_MSG_MAP(CMainFrame)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code !
	ON_WM_CREATE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

static UINT indicators[] =
{
	ID_SEPARATOR,           // status line indicator
	ID_INDICATOR_CAPS,
	ID_INDICATOR_NUM,
	ID_INDICATOR_SCRL,
};

/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction

CMainFrame::CMainFrame()
{
	// TODO: add member initialization code here
	
}

CMainFrame::~CMainFrame()
{
}

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}

	if (!m_wndStatusBar.Create(this) ||
		!m_wndStatusBar.SetIndicators(indicators,
		  sizeof(indicators)/sizeof(UINT)))
	{
		TRACE0("Failed to create status bar\n");
		return -1;      // fail to create
	}

	// TODO: Delete these three lines if you don't want the toolbar to
	//  be dockable
	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
	EnableDocking(CBRS_ALIGN_ANY);
	DockControlBar(&m_wndToolBar);

	return 0;
}

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
	if( !CFrameWnd::PreCreateWindow(cs) )
		return FALSE;
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics

#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
	CFrameWnd::AssertValid();
}

void CMainFrame::Dump(CDumpContext& dc) const
{
	CFrameWnd::Dump(dc);
}

#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers

#ifndef FOUR_PANEL_TEST

BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
{

// Create the first, basic wplitter window. This will
// a vertical split (two rows and one column).
//
	if (!m_wndSplitter.CreateStatic(this, 2, 1))
		return FALSE;

//***************************************************
//
//	Add the second splitter pane in the first row of the
//	first splitter. This new splitter window will have
//	two columns, each of which will be divided further.
//
//***************************************************
	if (!m_wndSplitter2.CreateStatic(
		&m_wndSplitter,   // parent window is first splitter
		1, 2,			  // new splitter is 1 row, 2 cols
		WS_CHILD | WS_VISIBLE | WS_BORDER,	// WS_BORDER is
											// needed
		m_wndSplitter.IdFromRowCol(0, 0)
// new splitter is in the first row, first column of
// first splitter
	   ))
	{
		TRACE0("Failed to create nested splitter\n");
		return FALSE;
	}

//***************************************************
//
//	Now split the left half of the second splitter into
//	another splitter window with two columns. This will be
//	the left directory listing, and the left pane will
//	contain the tree view and the right pane the list view.
//
//***************************************************
	if (!m_wndSplitter3.CreateStatic(
		&m_wndSplitter2, // parent window is second splitter
		1, 2,			 // new splitter is 1 row, 2 columns
		WS_CHILD | WS_VISIBLE | WS_BORDER,	// WS_BORDER is
											// needed
		m_wndSplitter2.IdFromRowCol(0, 0)
// new splitter is in the first row, first column of
// second splitter
	   ))
	{
		TRACE0("Failed to create nested splitter\n");
		return FALSE;
	}
//***************************************************
//
// Finally, split the right half of the second splitter into
// another splitter window, again with with two columns.
//
//***************************************************
	if (!m_wndSplitter4.CreateStatic(
		&m_wndSplitter2, // parent window is second splitter
		2, 1,			 // the new splitter is 2 rows,
						 // 1 column
		WS_CHILD | WS_VISIBLE | WS_BORDER,	// WS_BORDER is
											// needed
		m_wndSplitter2.IdFromRowCol(0, 1)
// new splitter is in the first row, 2nd columm
// of second splitter
	   ))
	{
		TRACE0("Failed to create nested splitter\n");
		return FALSE;
	}

//***************************************************
//
//	Now create the views inside the various panes.
//
//***************************************************
//***************************************************
//
//	Create a view in pane 0,0 of the upper left pane.
//
//***************************************************
	if (!m_wndSplitter3.CreateView(0, 0,
		RUNTIME_CLASS(CFirstView), CSize(10, 10), NULL))
	{
		TRACE0("Failed to create view for upper pane 1\n");
		return FALSE;
	}
//***************************************************
//
//	. . . and a view in pane 0,1 of the left pane.
//
//***************************************************
	if (!m_wndSplitter3.CreateView(0, 1,
		RUNTIME_CLASS(CFirstView), CSize(10, 10), NULL))
	{
		TRACE0("Failed to create view for upper pane 2\n");
		return FALSE;
	}

//***************************************************
//
//	Now create a view in pane 0,0 of the right pane.
//
//***************************************************
	if (!m_wndSplitter4.CreateView(0, 0,
		RUNTIME_CLASS(CFirstView), CSize(10, 10), pContext))
	{
		TRACE0("Failed to create view for upper pane 3\n");
		return FALSE;
	}
//***************************************************
//
//	. . . and a view in pane 1,0 of the right pane.
//
//***************************************************
	if (!m_wndSplitter4.CreateView(1, 0,
		RUNTIME_CLASS(CFirstView), CSize(10, 10), pContext))
	{
		TRACE0("Failed to create view for upper pane 4\n");
		return FALSE;
	}
//***************************************************
//
//	Create the primary view. This will be the one the
//	document object uses to read and write the text file.
//	Put this view in the second row of the original
//	splitter window.
//
//***************************************************
	if (!m_wndSplitter.CreateView(1, 0,
		RUNTIME_CLASS(CFirstView), CSize(50, 0), pContext))
	{
		TRACE0("Failed to create lower pane view\n");
		return FALSE;
	}

//
//	Set the size information for the various panes. If you
//	don't, they'll all be crowded into the upper left
//	corner. Give the lower pane a bit more room.
//
	CRect rc;
	GetClientRect (rc);

	m_wndSplitter.SetRowInfo(0, rc.bottom / 3, 0);
	m_wndSplitter.SetRowInfo(1, rc.bottom / 2, 0);

	m_wndSplitter2.SetColumnInfo(0, rc.right / 2, 0);
	m_wndSplitter2.SetColumnInfo(1, rc.right / 2, 0);

	m_wndSplitter3.SetColumnInfo(0, rc.right / 4, 0);
	m_wndSplitter3.SetColumnInfo(1, rc.right / 4, 0);

	m_wndSplitter4.SetRowInfo(0, rc.bottom / 6, 0);
	m_wndSplitter4.SetRowInfo(1, rc.bottom / 6, 0);

//
//	Set the active pane and active view to the primary
//	view, which is the view at the bottom of the window.
//
	m_wndSplitter.SetActivePane (1, 0);
	m_Primary = (CFirstView *) m_wndSplitter.GetPane (1, 0);
	if (m_Primary != NULL)
		SetActiveView (m_Primary);
	return (TRUE);
}

#else

BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
{

// Create the first, basic wplitter window. This will
// a vertical split (two rows and one column).
//
	if (!m_wndSplitter.CreateStatic(this, 2, 1))
		return FALSE;

//***************************************************
//
//	Add the second splitter pane in the first row of the
//	first splitter. This new splitter window will have
//	two columns, each of which will be divided further.
//
//***************************************************
	if (!m_wndSplitter2.CreateStatic(
		&m_wndSplitter,   // parent window is first splitter
		1, 4,			  // new splitter is 1 row, 2 cols
		WS_CHILD | WS_VISIBLE | WS_BORDER,	// WS_BORDER is
											// needed
		m_wndSplitter.IdFromRowCol(0, 0)
// new splitter is in the first row, first column of
// first splitter
	   ))
	{
		TRACE0("Failed to create nested splitter\n");
		return FALSE;
	}

	CRect rc;
	GetClientRect (rc);
	int nWidth = rc.right / 4;
	if (!m_wndSplitter.CreateView(1, 0,
		RUNTIME_CLASS(CFirstView), CSize(100, 100), pContext))
	{
		TRACE0("Failed to create view for upper pane 3\n");
		return FALSE;
	}

	if (!m_wndSplitter2.CreateView(0, 0,
		RUNTIME_CLASS(CFirstView), CSize(nWidth, 100), pContext))
	{
		TRACE0("Failed to create view for upper pane 3\n");
		return FALSE;
	}

	if (!m_wndSplitter2.CreateView(0, 1,
		RUNTIME_CLASS(CFirstView), CSize(nWidth, 100), pContext))
	{
		TRACE0("Failed to create view for upper pane 3\n");
		return FALSE;
	}

	if (!m_wndSplitter2.CreateView(0, 2,
		RUNTIME_CLASS(CFirstView), CSize(nWidth, 100), pContext))
	{
		TRACE0("Failed to create view for upper pane 3\n");
		return FALSE;
	}

	if (!m_wndSplitter2.CreateView(0, 3,
		RUNTIME_CLASS(CFirstView), CSize(nWidth, 100), pContext))
	{
		TRACE0("Failed to create view for upper pane 3\n");
		return FALSE;
	}
//
//	Set the size information for the various panes. If you
//	don't, they'll all be crowded into the top of the
//	window. Give the lower pane a bit more room.
//
	m_wndSplitter.SetRowInfo(0, rc.bottom / 3, 0);
	m_wndSplitter.SetRowInfo(1, rc.bottom / 2, 0);
	return (TRUE);
}
#endif		//	FOUR_PANEL_TEST

⌨️ 快捷键说明

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