📄 msgdlg.cpp
字号:
// MSGDLG.cpp : implementation file
//
#include "stdafx.h"
#include "AdbonWZQ.h"
#include "MSGDLG.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMSGDLG dialog
CMSGDLG::CMSGDLG(CWnd* pParent /*=NULL*/)
: CDialog(CMSGDLG::IDD, pParent)
{
//{{AFX_DATA_INIT(CMSGDLG)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CMSGDLG::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMSGDLG)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMSGDLG, CDialog)
//{{AFX_MSG_MAP(CMSGDLG)
ON_BN_CLICKED(IDC_BUTOK, OnButok)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMSGDLG message handlers
void CMSGDLG::OnButok()
{
// TODO: Add your control notification handler code here
OnOK();
}
void CMSGDLG::SetShowType(int nval)
{
// HICON m_ic1;
if (nval!=0)
{
//输了
m_tile="我又赢了哦^_^";
::SetWindowText(GetDlgItem(IDC_STILE)->m_hWnd,L"本局小屁孩(计算机)获取胜利");
::SetWindowText(GetDlgItem(IDC_SNAME)->m_hWnd,L"小屁孩:");
::SetWindowText(GetDlgItem(IDC_SSHOU)->m_hWnd,L"小样,输了吧,回去再练几年吧! ^_^ ^_^ ");
// CStatic *m_ico=(CStatic *)GetDlgItem(IDC_IPIC);
// m_ic1=::LoadIcon(::AfxGetInstanceHandle(),(LPCTSTR)IDB_QZB16);
m_win=0;//输
}
else
{
//输了
m_tile="-_-又输了...";
::SetWindowText(GetDlgItem(IDC_STILE)->m_hWnd,L"本局 玩家 获取胜利");
::SetWindowText(GetDlgItem(IDC_SNAME)->m_hWnd,L"小屁孩:");
::SetWindowText(GetDlgItem(IDC_SSHOU)->m_hWnd,L"-_- 你是不是作弊了啊,再来两盘...");
// CStatic *m_ico=(CStatic *)GetDlgItem(IDC_IPIC);
// m_ic1=::LoadIcon(::AfxGetInstanceHandle(),(LPCTSTR)IDB_QZH16);
// m_ico->SetIcon();
m_win=1;//输
}
}
void CMSGDLG::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(m_tile,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);
//打印图标
if (m_win==0)
{
hdc.DrawIcon(CPoint(20,60),::LoadIcon(::AfxGetInstanceHandle(),(LPCTSTR)IDB_QZB16));
}
else
{
hdc.DrawIcon(CPoint(20,60),::LoadIcon(::AfxGetInstanceHandle(),(LPCTSTR)IDB_QZH16));
}
// Do not call CDialog::OnPaint() for painting messages
}
BOOL CMSGDLG::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
::SetWindowText(GetDlgItem(IDC_BUTOK)->m_hWnd,L"确定");
CBitmap temp;
temp.LoadBitmap(IDB_HENT);
m_HenMemDC.CreateCompatibleDC(NULL);
m_HenMemDC.SelectObject(&temp);
temp.DeleteObject();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -