📄 billiardsformview.cpp
字号:
// BilliardsFormView.cpp : implementation file
//
#include "stdafx.h"
#include "Billiards.h"
#include "BilliardsFormView.h"
#include "BilliardsDoc.h"
#include "BilliardsPlayView.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBilliardsFormView
IMPLEMENT_DYNCREATE(CBilliardsFormView, CFormView)
CBilliardsFormView::CBilliardsFormView()
: CFormView(CBilliardsFormView::IDD)
{
//{{AFX_DATA_INIT(CBilliardsFormView)
m_strMSG = _T("");
m_WhiteBrush=new CBrush(HS_CROSS,RGB(255,255,255));
m_BlueBrush=new CBrush(HS_CROSS,RGB(220,220,255));
//}}AFX_DATA_INIT
}
CBilliardsFormView::~CBilliardsFormView()
{
}
void CBilliardsFormView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CBilliardsFormView)
DDX_Control(pDX, IDC_PROGRESS_POWER, m_ctlProgressPower);
DDX_Control(pDX, IDC_LIST_MSG, m_ctlListMSG);
DDX_Text(pDX, IDC_EDIT_MSG, m_strMSG);
DDX_Control(pDX, IDC_BUTTON_SEND, m_BtnSend);
DDX_Control(pDX, IDC_BUTTON_SHOOT, m_BtnShoot);
//}}AFX_DATA_MAP
m_ctlProgressPower.SetRange(0,100);
m_ctlProgressPower.SetPos(0);
}
BEGIN_MESSAGE_MAP(CBilliardsFormView, CFormView)
//{{AFX_MSG_MAP(CBilliardsFormView)
ON_BN_CLICKED(IDC_BUTTON_SEND, OnButtonSend)
ON_BN_CLICKED(IDC_BUTTON_SHOOT, OnButtonShoot)
ON_WM_CTLCOLOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBilliardsFormView diagnostics
#ifdef _DEBUG
void CBilliardsFormView::AssertValid() const
{
CFormView::AssertValid();
}
void CBilliardsFormView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
#endif //_DEBUG
CBilliardsDoc* CBilliardsFormView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CBilliardsDoc)));
return (CBilliardsDoc*)m_pDocument;
}
void CBilliardsFormView::OnButtonSend()
{
CBilliardsDoc* pDoc = GetDocument();
CPropertyItem* pItem;
UpdateData();
if(m_strMSG.IsEmpty())
{
AfxMessageBox("空消息不发送",MB_OK);
pItem=NULL;
}
else
{
if(pDoc->m_bPlayer==SERVER)
pItem = new CPropertyItem(pDoc->m_strServer,m_strMSG,PIT_EDIT,"");
else
pItem = new CPropertyItem(pDoc->m_strClient,m_strMSG,PIT_EDIT,"");
m_ctlListMSG.AddPropItem(pItem);
m_strMSG.Insert(0,"1");
pDoc->m_pClientSocket->Send(m_strMSG,m_strMSG.GetLength());
}
}
void CBilliardsFormView::OnButtonShoot()
{
CBilliardsPlayView *pView=(CBilliardsPlayView *)((CMainFrame *)AfxGetMainWnd())->m_wndSplitter.GetPane(0,0);
pView->HitBall();
}
HBRUSH CBilliardsFormView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor);
/*
if(nCtlColor==CTLCOLOR_DLG||nCtlColor==CTLCOLOR_STATIC||nCtlColor==CTLCOLOR_BTN){
pDC->SetBkColor(RGB(255,255,255));
return (HBRUSH)(m_WhiteBrush->GetSafeHandle());
}
*/
if(nCtlColor==CTLCOLOR_EDIT||nCtlColor==CTLCOLOR_LISTBOX)
{
pDC->SetBkColor(RGB(220,220,255));
return (HBRUSH)(m_BlueBrush->GetSafeHandle());
}
return hbr;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -