topsplitview.cpp

来自「VisualC++通信编程工程实例精解 Chapter 2 Example」· C++ 代码 · 共 93 行

CPP
93
字号
// TopSplitView.cpp : implementation file
//

#include "stdafx.h"
#include "OpcClientSpy.h"

#include "TopSplitView.h"
#include "ServerInfoView.h"
#include "ValueMsgView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CTopSplitView

IMPLEMENT_DYNCREATE(CTopSplitView, CView)

CTopSplitView::CTopSplitView()
{
}

CTopSplitView::~CTopSplitView()
{
}


BEGIN_MESSAGE_MAP(CTopSplitView, CView)
	//{{AFX_MSG_MAP(CTopSplitView)
	ON_WM_CREATE()
	ON_WM_SIZE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTopSplitView drawing

void CTopSplitView::OnDraw(CDC* pDC)
{
	CDocument* pDoc = GetDocument();
	// TODO: add draw code here
}

/////////////////////////////////////////////////////////////////////////////
// CTopSplitView diagnostics

#ifdef _DEBUG
void CTopSplitView::AssertValid() const
{
	CView::AssertValid();
}

void CTopSplitView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CTopSplitView message handlers

int CTopSplitView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CView::OnCreate(lpCreateStruct) == -1)
		return -1;

	m_leftRightSplitter.CreateStatic(this, 1, 2);
	CCreateContext *pContext = (CCreateContext*) lpCreateStruct->lpCreateParams;
	CRect rect;
	GetWindowRect(&rect);

	m_leftRightSplitter.CreateView(0,0,RUNTIME_CLASS(CServerInfoView), CSize(rect.Width()/3,0), pContext);
	m_leftRightSplitter.CreateView(0,1,RUNTIME_CLASS(CValueMsgView), CSize(0,0), pContext);

	return 0;
}

void CTopSplitView::OnSize(UINT nType, int cx, int cy) 
{
	CView::OnSize(nType, cx, cy);
	//去掉视图中的边框	
	//不是用m_leftRightSplitter.MoveWindow(0,0,cx,cy);
	m_leftRightSplitter.MoveWindow(-2,-2,cx+4,cy+4);
	//下面这段代码放在OnCreate中不起作用。
	m_leftRightSplitter.SetColumnInfo(0, cx/3, 0);
	m_leftRightSplitter.SetColumnInfo(1, cx-cx/3, 20);
	m_leftRightSplitter.RecalcLayout();	
}

⌨️ 快捷键说明

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