⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 空当接龙dlg.cpp

📁 实习时做的空档接龙纸牌游戏
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// 空当接龙Dlg.cpp : implementation file
//

#include "stdafx.h"
#include "空当接龙.h"
#include "空当接龙Dlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyDlg dialog

CMyDlg::CMyDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CMyDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CMyDlg)
		// 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);
	m_txnb=1;
	m_xsdh=false;
	m_ynks=false;
	m_thegame= new Cgame();
	m_pai[0].LoadBitmap(IDB_HT1);//加载牌位图
	m_pai[1].LoadBitmap(IDB_HT2);
	m_pai[2].LoadBitmap(IDB_HT3);
	m_pai[3].LoadBitmap(IDB_HT4);
	m_pai[4].LoadBitmap(IDB_HT5);
	m_pai[5].LoadBitmap(IDB_HT6);
	m_pai[6].LoadBitmap(IDB_HT7);
	m_pai[7].LoadBitmap(IDB_HT8);
	m_pai[8].LoadBitmap(IDB_HT9);
	m_pai[9].LoadBitmap(IDB_HT10);
	m_pai[10].LoadBitmap(IDB_HT11);
	m_pai[11].LoadBitmap(IDB_HT12);
	m_pai[12].LoadBitmap(IDB_HT13);
	m_pai[13].LoadBitmap(IDB_HTT1);
	m_pai[14].LoadBitmap(IDB_HTT2);
	m_pai[15].LoadBitmap(IDB_HTT3);
	m_pai[16].LoadBitmap(IDB_HTT4);
	m_pai[17].LoadBitmap(IDB_HTT5);
	m_pai[18].LoadBitmap(IDB_HTT6);
	m_pai[19].LoadBitmap(IDB_HTT7);
	m_pai[20].LoadBitmap(IDB_HTT8);
	m_pai[21].LoadBitmap(IDB_HTT9);
	m_pai[22].LoadBitmap(IDB_HTT10);
	m_pai[23].LoadBitmap(IDB_HTT11);
	m_pai[24].LoadBitmap(IDB_HTT12);
	m_pai[25].LoadBitmap(IDB_HTT13);
	m_pai[26].LoadBitmap(IDB_MH1);
	m_pai[27].LoadBitmap(IDB_MH2);
	m_pai[28].LoadBitmap(IDB_MH3);
	m_pai[29].LoadBitmap(IDB_MH4);
	m_pai[30].LoadBitmap(IDB_MH5);
	m_pai[31].LoadBitmap(IDB_MH6);
	m_pai[32].LoadBitmap(IDB_MH7);
	m_pai[33].LoadBitmap(IDB_MH8);
	m_pai[34].LoadBitmap(IDB_MH9);
	m_pai[35].LoadBitmap(IDB_MH10);
	m_pai[36].LoadBitmap(IDB_MH11);
	m_pai[37].LoadBitmap(IDB_MH12);
	m_pai[38].LoadBitmap(IDB_MH13);
	m_pai[39].LoadBitmap(IDB_FP1);
	m_pai[40].LoadBitmap(IDB_FP2);
	m_pai[41].LoadBitmap(IDB_FP3);
	m_pai[42].LoadBitmap(IDB_FP4);
	m_pai[43].LoadBitmap(IDB_FP5);
	m_pai[44].LoadBitmap(IDB_FP6);
	m_pai[45].LoadBitmap(IDB_FP7);
	m_pai[46].LoadBitmap(IDB_FP8);
	m_pai[47].LoadBitmap(IDB_FP9);
	m_pai[48].LoadBitmap(IDB_FP10);
	m_pai[49].LoadBitmap(IDB_FP11);
	m_pai[50].LoadBitmap(IDB_FP12);
	m_pai[51].LoadBitmap(IDB_FP13);
}

void CMyDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMyDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
	//{{AFX_MSG_MAP(CMyDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_WM_CTLCOLOR()
	ON_WM_LBUTTONDOWN()
	ON_WM_MOUSEMOVE()
	ON_COMMAND(ID_begin, Onbegin)
	ON_WM_LBUTTONDBLCLK()
	ON_WM_RBUTTONDOWN()
	ON_WM_RBUTTONUP()
	ON_WM_MOVE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyDlg message handlers

BOOL CMyDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// 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
	
	// TODO: Add extra initialization here
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CMyDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CMyDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
	if(m_txnb==2)
	{ 
	 CDC *thedc=GetDC();
	 CDC jrdc;
	 CBitmap map;
	 map.LoadBitmap(IDB_TXY);
	 BITMAP bmp;
     map.GetBitmap(&bmp);
	 jrdc.CreateCompatibleDC(thedc);
	 jrdc.SelectObject(&map);
	 thedc->StretchBlt(297,18,38,38,&jrdc,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY);
	 ReleaseDC(thedc);
	}
	if(m_ynks==true)
	{ 		
		for(int i=0,x=10;i<8;i++,x+=77)//显示牌
		{
		 for(int j=0,y=100;j<19;j++,y+=18)
		 {
			 if(m_thegame->m_gamep[i][j].ds==0)
			 {
				 break;
			 }
			 CDC *thedc=GetDC();
			 CDC jrdc;
			 BITMAP bmp;
			 m_pai[0].GetBitmap(&bmp);
			 jrdc.CreateCompatibleDC(thedc);
			 jrdc.SelectObject(&m_pai[m_thegame->m_gamep[i][j].zb]);
			 thedc->StretchBlt(x,y,70,97,&jrdc,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY);
			 ReleaseDC(thedc);
		 }
		}
	 if(m_thegame->m_cunps!=4)//如果左上角有牌
	 {       
		 for(int i=0;i<4;i++)
		 {  
			if(m_thegame->m_cunp[i].zb!=-1)
			{
			 CDC *thedc=GetDC();
			 CDC jrdc;
			 BITMAP bmp;
			 m_pai[0].GetBitmap(&bmp);
			 jrdc.CreateCompatibleDC(thedc);
             jrdc.SelectObject(&m_pai[m_thegame->m_cunp[i].zb]);
		     thedc->StretchBlt(i*71,0,70,97,&jrdc,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY);
			 ReleaseDC(thedc);
			}
		 }		
	 }
	 if(m_thegame->m_xuanp[0].zb!=-1&&m_thegame->m_lies!=-1&&m_thegame->m_lies<10)
	 {
		CDC *thedc=GetDC();
		CDC jrdc;
		BITMAP bmp;
		CBitmap bitmap;
		bitmap.LoadBitmap(IDB_XZK);
		bitmap.GetBitmap(&bmp);
		jrdc.CreateCompatibleDC(thedc);
		jrdc.SelectObject(&bitmap);
		thedc->StretchBlt(m_thegame->m_lies*77+10+17,m_thegame->m_pshu[m_thegame->m_lies]*18+100+25-18,36,40,&jrdc,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY);
        ReleaseDC(thedc);
	 }
	 if(m_thegame->m_xuanp[0].zb!=-1&&m_thegame->m_lies!=-1&&m_thegame->m_lies>=10)
	 {
         CDC *thedc=GetDC();
	 	 CDC jrdc;
		 BITMAP bmp;
		 CBitmap bitmap;
		 bitmap.LoadBitmap(IDB_XZK);
		 bitmap.GetBitmap(&bmp);
		 jrdc.CreateCompatibleDC(thedc);
		 jrdc.SelectObject(&bitmap);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -