📄 adbonwzqdlg.cpp
字号:
// AdbonWZQDlg.cpp : implementation file
//
#include "stdafx.h"
#include "AdbonWZQ.h"
#include "AdbonWZQDlg.h"
#include "MSGDLG.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAdbonWZQDlg dialog
CAdbonWZQDlg::CAdbonWZQDlg(CWnd* pParent /*=NULL*/)
: CDialog(CAdbonWZQDlg::IDD, pParent)
{
CBitmap b,c,d,e,f;
CSize x;
b.LoadBitmap(IDB_QP242);
x.cx =242;//446 ;
x.cy =242;//446;
qp.CreateCompatibleDC(NULL);
qp.SelectObject(&b);
qp.SetSize(x);
b.DeleteObject();
c.LoadBitmap(IDB_QZH16);
x.cx =16;// 27 ;
x.cy =16;//27 ;
qzh.CreateCompatibleDC(NULL);
qzh.SelectObject(&c);
qzh.SetSize(x);
c.DeleteObject();
d.LoadBitmap(IDB_QZB16);
x.cx = 16;//27 ;
x.cy =16;//27;
qzb.CreateCompatibleDC(NULL);
qzb.SelectObject(&d);
qzb.SetSize(x);
d.DeleteObject();
e.LoadBitmap(IDB_MASK17);
x.cx =16;// 27 ;
x.cy =16;//27;
mask.CreateCompatibleDC(NULL);
mask.SelectObject(&e);
mask.SetSize(x);
d.DeleteObject();
f.LoadBitmap(IDB_DEAD16);
x.cx=16;//27;
x.cy=16;//27;
dead.CreateCompatibleDC(NULL);
dead.SelectObject(&f);
dead.SetSize(x);
f.DeleteObject();
//{{AFX_DATA_INIT(CAdbonWZQDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CAdbonWZQDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAdbonWZQDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAdbonWZQDlg, CDialog)
//{{AFX_MSG_MAP(CAdbonWZQDlg)
ON_BN_CLICKED(IDC_BUTNEW, OnButnew)
ON_BN_CLICKED(IDC_BUTBACK, OnButback)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAdbonWZQDlg message handlers
BOOL CAdbonWZQDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
CenterWindow(GetDesktopWindow()); // center to the hpc screen
SetWindowPos(this,0,26,240,294,SWP_SHOWWINDOW);
// MoveWindow(0,0,240,320);
CRect rcdlg,rcc;
GetClientRect(rcdlg);
CButton * m_ctrl=(CButton *)GetDlgItem(IDC_BUTNEW);
rcc.left=8;
rcc.top=rcdlg.Height()-28;
rcc.right=rcc.left+50;
rcc.bottom=rcc.top+23;
m_ctrl->SetWindowText(TEXT("新游戏"));
m_ctrl->MoveWindow(rcc);
m_ctrl=(CButton *)GetDlgItem(IDC_BUTBACK);
rcc.left=rcdlg.Width()-58;
rcc.right=rcc.left+50;
m_ctrl->MoveWindow(rcc);
m_ctrl->SetWindowText(TEXT("悔棋"));
// m_new->Create(L"新游戏",WS_CHILD | WS_VISIBLE,CRect(10,rcdlg.Height()-30,50,26),this,2015);
/*
// m_new.MoveWindow(10,rcdlg.Height()-30,50,26,TRUE);
m_new.SetWindowPos(this,10,rcdlg.Height()-30,50,26,SWP_SHOWWINDOW);
m_new.SetWindowText(L"新游戏");
// m_back.MoveWindow(234,rcdlg.Height()-30,50,26);
m_back.SetWindowText(L"悔 棋");
*/
CBitmap temp;
temp.LoadBitmap(IDB_HENT);
m_HenMemDC.CreateCompatibleDC(NULL);
m_HenMemDC.SelectObject(&temp);
temp.DeleteObject();
this->SetWindowText(L"五子棋 v1.0");
runpath ="";
loadfile();
twzq.SetDc(&qp,&qzh,&qzb,&mask,&dead,this->GetDC());
twzq.NewGame();
GetDlgItem(IDC_BUTBACK)->EnableWindow(twzq.getbackble());
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CAdbonWZQDlg::OnButnew()
{
// TODO: Add your control notification handler code here
Invalidate();
twzq.NewGame();
GetDlgItem(IDC_BUTBACK)->EnableWindow(twzq.getbackble());
}
void CAdbonWZQDlg::OnButback()
{
// TODO: Add your control notification handler code here
twzq.goback();
GetDlgItem(IDC_BUTBACK)->EnableWindow(twzq.getbackble());
}
void CAdbonWZQDlg::loadfile()
{
twzq.AItype=2;
twzq.Model=0;
}
void CAdbonWZQDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
int x1,y1;
x1=(int)(point.x+2)/16 ;
y1=(int)(point.y+2-32)/16 ;
if(!twzq.downzi(x1,y1))
{
return;
}
GetDlgItem(IDC_BUTBACK)->EnableWindow(twzq.getbackble());
if (twzq.twinner.winner==1)
{
/* CMSGDLG dlg;
dlg.SetShowType();
dlg.DoModal();
*/
MessageBox(L"小样,输了吧,回去再练几年吧! ^_^ ^_^");
GetDlgItem(IDC_BUTBACK)->EnableWindow(FALSE);
twzq.draw();
}
if (twzq.twinner.winner==2)
{
/*
CMSGDLG dlg;
dlg.SetShowType(1);
dlg.DoModal();
*/
MessageBox(L"-_- 你是不是作弊了啊,再来两盘..." );
GetDlgItem(IDC_BUTBACK)->EnableWindow(FALSE);
twzq.draw();
}
CDialog::OnLButtonDown(nFlags, point);
}
void CAdbonWZQDlg::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CRect closerect,dlgrect;
GetClientRect(&dlgrect);
if (point.x>=dlgrect.Width()-25 && point.x<dlgrect.Width()-8 && point.y>=3 && point.y<=20)
OnCancel();
CDialog::OnLButtonUp(nFlags, point);
}
void CAdbonWZQDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CClientDC hdc(this);
CRect rcdlg,rcx,closerect;
GetWindowRect(&rcdlg);
rcx.left=2;
rcx.top=2;
rcx.right=rcdlg.Width()-2;
rcx.bottom=rcdlg.Height()-2;
HBRUSH m_closebrush=::CreateSolidBrush(RGB(210,227,230));
HBRUSH m_oldclosebrush=(HBRUSH)hdc.SelectObject(m_closebrush);
hdc.RoundRect(rcx,CPoint(8,8));
hdc.SelectObject(m_oldclosebrush);
hdc.BitBlt(4,3,rcdlg.Width()-8,23,&m_HenMemDC,3,0,SRCCOPY);
//打印标题
CString temp;
temp="五子棋 v1.0";
hdc.SetBkMode(0);
hdc.DrawText(temp,CRect(10,6,120,22),0);
//画关闭圆
closerect.left=rcdlg.Width()-25;
closerect.top=3;
closerect.right=rcdlg.Width()-8;
closerect.bottom=20;
m_closebrush=::CreateSolidBrush(RGB(242,232,207));
m_oldclosebrush=(HBRUSH)hdc.SelectObject(m_closebrush); //hdc.SelectObject(m_closebrush);
CPen m_closepen;
m_closepen.CreatePen(PS_SOLID,1,RGB(252,212,207));
CPen *m_oldclosepen=hdc.SelectObject(&m_closepen); //hdc.SelectObject(&m_closepen);
hdc.Ellipse(closerect);
hdc.SelectObject(m_oldclosebrush);
hdc.SelectObject(m_oldclosepen);
m_oldclosepen->Detach();
m_oldclosepen->DeleteObject();
CSize size=hdc.GetTextExtent("X");
hdc.SetBkMode(TRANSPARENT);
hdc.DrawText("X",CRect((closerect.left+(closerect.Width()-size.cx)/2),(closerect.top+(closerect.Height()-size.cy)/2),closerect.right,closerect.bottom),0);
CSize x;
x=qp.GetSize();
twzq.draw();
// Do not call CDialog::OnPaint() for painting messages
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -