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

📄 gamehallframe.cpp

📁 Visual C++网络游戏建模与实现(第2版)
💻 CPP
字号:
// gamehallframe.cpp : implementation file
//

#include "stdafx.h"
#include "..\GameHigh.h"
#include "gamehallframe.h"
#include "macros.h"

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

/////////////////////////////////////////////////////////////////////////////
// CGameHallFrame

BEGIN_MESSAGE_MAP(CGameHallFrame, CFrameWnd)
	//{{AFX_MSG_MAP(CGameHallFrame)
	ON_WM_CREATE()
	ON_WM_PAINT()
	ON_WM_SIZE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

CGameHallFrame::CGameHallFrame(CWnd* pWnd, RECT rcWnd)
{
	pServerTreeView	=NULL;

	pSystemMsgView	=NULL;

	pWebAdvertView	=NULL;

	bFirstRun		=FALSE;

	try
	{
		Create(NULL, "", 
			WS_CHILD | WS_VISIBLE, rcWnd, pWnd, NULL, NULL);
	}
	catch(...)
	{
		::AfxMessageBox("无法创建大厅窗口", MB_OK | MB_ICONERROR);
	}

	
}

CGameHallFrame::~CGameHallFrame()
{
}



/////////////////////////////////////////////////////////////////////////////
// CGameHallFrame message handlers

BOOL CGameHallFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
{
	if (NULL == m_wndSplitter.CreateStatic(this, 1, 2))
		return FALSE;
			
	m_wndSplitter.CreateView(0, 1,		//设置TreeView
		RUNTIME_CLASS(CHtmlViewEx),
		CSize(600,600),
		pContext); 


	RECT	rect;
	memset(&rect, 0, sizeof(RECT));
	this->GetClientRect(&rect);


	//拆分左边的栏
	if(NULL == m_wndLeftSplitter.CreateStatic(&m_wndSplitter,
				2, 1,
				WS_CHILD|WS_VISIBLE,
				m_wndSplitter.IdFromRowCol(0, 0))) 
		return FALSE;

	m_wndLeftSplitter.CreateView(0, 0, RUNTIME_CLASS(CServerTreeView),
		CSize(250,500), pContext);

	m_wndLeftSplitter.CreateView(1, 0, RUNTIME_CLASS(CSystemMsgView),
		CSize(250,100), pContext);


	SetActiveView((CView*)m_wndLeftSplitter.GetPane(0,0));

	pWebAdvertView	=(CHtmlViewEx*)m_wndSplitter.GetPane(0, 1);
	pServerTreeView	=(CServerTreeView*)m_wndLeftSplitter.GetPane(0, 0);
	pSystemMsgView	=(CSystemMsgView*)m_wndLeftSplitter.GetPane(1, 0);

	SAFE_CHECKWND(pWebAdvertView)
	{
		pWebAdvertView->Navigate2("www.GameHigh.net", 0, NULL);
	}
	return TRUE;
}

int CGameHallFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	this->ModifyStyleEx(WS_EX_OVERLAPPEDWINDOW , 0, 0);	
	return 0;
}

void CGameHallFrame::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	if(!bFirstRun)
	{
		bFirstRun	=TRUE;

		RECT	rect;
		memset(&rect, 0, sizeof(RECT));
		this->GetClientRect(&rect);

		CSplitterWnd*	pWnd	=&m_wndSplitter;
		SAFE_CHECKWND(pWnd)
		{
			pWnd->SetColumnInfo(0, rect.right/4, 100);
			pWnd->SetColumnInfo(1, (rect.right/4) * 3, 100);
			pWnd->RecalcLayout();
		}
	}
}

void CGameHallFrame::OnSize(UINT nType, int cx, int cy) 
{
	CFrameWnd::OnSize(nType, cx, cy);
}

⌨️ 快捷键说明

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