📄 mainfrm.cpp
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "WeiQiClient.h"
#include "MainFrm.h"
#include "WeiQiClientDoc.h"
#include "WeiQiClientView.h"
#include "WeiQiSocket.h"
#include "Client.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
// TODO: add member initialization code here
}
CMainFrame::~CMainFrame()
{
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
cs.cx=470;
cs.cy=453;
cs.style=WS_SYSMENU|WS_MINIMIZEBOX;
cs.lpszName=_T("网络围棋");
cs.hMenu=NULL;
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
void CMainFrame::OnDestroy()
{
CFrameWnd::OnDestroy();
// TODO: Add your message handler code here
if(((CWeiQiClientApp*)AfxGetApp())->m_pClient->m_pSocket!=NULL)
{
CString Msg;
if(((CWeiQiClientApp*)AfxGetApp())->m_pClient->m_InGame)
{
Msg=_T("_QUITGAME1 "); //退出当前游戏,关闭连接
Msg+=((CWeiQiClientApp*)AfxGetApp())->m_pClient->m_GameName;
((CWeiQiClientApp*)AfxGetApp())->m_pClient->SendMsg(Msg);
}
else
{
Msg=_T("_QUITGAME0 "); //关闭连接
((CWeiQiClientApp*)AfxGetApp())->m_pClient->SendMsg(Msg);
}
DWORD dwTime2;
DWORD dwTime1 = dwTime2 = GetTickCount();
while(dwTime2 - dwTime1 < 10000
&& !((CWeiQiClientApp*)AfxGetApp())->m_pClient->FetchMsg())
{
dwTime2 = GetTickCount();
Sleep(100);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -