MainFrm.cpp
资源名称:1731.rar [点击查看]
上传用户:swkcbjrc
上传日期:2016-04-02
资源大小:45277k
文件大小:4k
源码类别:
游戏
开发平台:
Visual C++
- // MainFrm.cpp : implementation of the CMainFrame class
- //
- #include "stdafx.h"
- #include "GameHigh.h"
- #include "MainFrm.h"
- #include "GameHallFrame.h"
- #include "Macros.h"
- #include "MainData.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame
- extern CGameHighApp theApp;
- IMPLEMENT_DYNAMIC(CMainFrame, CFrameWnd)
- BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
- //{{AFX_MSG_MAP(CMainFrame)
- ON_WM_CREATE()
- ON_WM_SIZE()
- ON_WM_ERASEBKGND()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame construction/destruction
- CMainFrame::CMainFrame(LPCTSTR lpszUser, LPCTSTR lpszPass)
- {
- ASSERT(lpszUser);
- ASSERT(lpszPass);
- if(NULL == lpszUser ||
- NULL == lpszPass ||
- 0 == strlen(lpszUser) ||
- 0 == strlen(lpszPass))
- {
- return ;
- }
- pGameHallFrame =NULL;
- pTableFrame =NULL;
- if(!Login(lpszUser, lpszPass))
- {
- ASSERT(NULL);
- }
- try
- {
- Create(NULL, "军棋 Alpha 0.01",
- WS_OVERLAPPEDWINDOW, rectDefault, NULL, NULL, NULL);
- }
- catch(...)
- {
- ::AfxMessageBox("无法创建主窗口", MB_OK | MB_ICONERROR);
- }
- }
- CMainFrame::~CMainFrame()
- {
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame diagnostics
- #ifdef _DEBUG
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame message handlers
- int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
- return -1;
- this->ModifyStyleEx(WS_EX_OVERLAPPEDWINDOW , 0, 0);
- m_wndTopBar.Create(this);
- RECT rect;
- memset(&rect, 0, sizeof(RECT));
- pGameHallFrame =new CGameHallFrame(this, rect);
- return 0;
- }
- void CMainFrame::OnSize(UINT nType, int cx, int cy)
- {
- CFrameWnd::OnSize(nType, cx, cy);
- const int nReBarHeight =50;
- SAFE_CHECKWND(pGameHallFrame)
- {
- RECT rect;
- memset(&rect, 0, sizeof(RECT));
- this->GetClientRect(&rect);
- rect.top =nReBarHeight;
- pGameHallFrame->MoveWindow(&rect, TRUE);
- }
- CWnd* pWnd =&m_wndTopBar;
- SAFE_CHECKWND(pWnd)
- {
- RECT rect;
- memset(&rect, 0, sizeof(RECT));
- this->GetClientRect(&rect);
- rect.bottom =nReBarHeight;
- pWnd->MoveWindow(&rect, TRUE);
- }
- SAFE_CHECKWND(pTableFrame)
- {
- RECT rect;
- memset(&rect, 0, sizeof(RECT));
- this->GetClientRect(&rect);
- rect.top =nReBarHeight;
- pTableFrame->MoveWindow(&rect, TRUE);
- }
- }
- void CMainFrame::ShowTableFrame(BOOL bShow, DWORD dwRoomID)
- {
- if(bShow)
- {
- if(NULL == pTableFrame)
- {
- pGameHallFrame->ShowWindow(SW_HIDE);
- if(NULL != pTableFrame || ::IsWindow(pTableFrame->GetSafeHwnd()))
- {
- return ;
- }
- const int nReBarHeight =50;
- RECT rect;
- memset(&rect, 0, sizeof(RECT));
- this->GetClientRect(&rect);
- rect.top =nReBarHeight;
- pTableFrame =new CTableFrame(this, rect);
- SAFE_CHECKWND(pTableFrame)
- {
- pTableFrame->MoveWindow(&rect);
- }
- }
- SAFE_CHECKWND(pTableFrame)
- {
- pTableFrame->ShowWindow(SW_SHOW);
- pTableFrame->SetRoomID(dwRoomID);
- }
- }
- else
- {
- SAFE_CHECKWND(pTableFrame)
- {
- pTableFrame->ShowWindow(SW_HIDE);
- pTableFrame->SendMessage(WM_DESTROY, 0, 0);
- pTableFrame =NULL;
- }
- SAFE_CHECKWND(pGameHallFrame)
- {
- pGameHallFrame->ShowWindow(SW_SHOW);
- }
- }
- }
- BOOL CMainFrame::Login(LPCTSTR lpszUser, LPCTSTR lpszPass)
- {
- ASSERT(lpszUser);
- ASSERT(lpszPass);
- if(NULL == lpszUser ||
- NULL == lpszPass ||
- 0 == strlen(lpszUser) ||
- 0 == strlen(lpszPass))
- {
- return FALSE;
- }
- CMainData* pMainData =NULL;
- pMainData =theApp.GetMainData();
- SAFE_CHECKPOINTER(pMainData)
- {
- pMainData->Async_GameHigh_Login(lpszUser, lpszPass);
- return TRUE;
- }
- return FALSE;
- }
- BOOL CMainFrame::OnEraseBkgnd(CDC* pDC)
- {
- return TRUE;
- }