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

📄 setgame.cpp

📁 VC汉诺塔游戏-能很好的演示过程
💻 CPP
字号:
// SetGame.cpp : implementation file
//

#include "stdafx.h"
#include "汉诺塔.h"
#include "SetGame.h"

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

/////////////////////////////////////////////////////////////////////////////
// CSetGame dialog


CSetGame::CSetGame(CWnd* pParent /*=NULL*/)
	: CDialog(CSetGame::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSetGame)
	//}}AFX_DATA_INIT
}


void CSetGame::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSetGame)
	DDX_Control(pDX, IDC_STICK_VIEW, m_StickView);
	DDX_Control(pDX, IDC_COLORBOX, m_ColorBox);
	DDX_Control(pDX, IDC_STICKS, m_Stick);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSetGame, CDialog)
	//{{AFX_MSG_MAP(CSetGame)
	ON_BN_CLICKED(IDC_SELECTCOLOR, OnSelectcolor)
	ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_STICKS, OnReleasedcaptureSticks)
	ON_WM_CTLCOLOR()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSetGame message handlers

void CSetGame::OnSelectcolor() 
{
	// TODO: Add your control notification handler code here
	CColorDialog dlg;

	if(dlg.DoModal()==IDOK)
	{
		m_bkcolor=dlg.GetColor();

		CClientDC dc(this);
		CRect rc;
		m_ColorBox.GetWindowRect(&rc);
		ScreenToClient(&rc);
		dc.FillSolidRect(&rc,m_bkcolor);
	}
}

BOOL CSetGame::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	m_Stick.SetRange(1,15);
	m_Stick.SetPos(m_sticks);
	CString s;
	s.Format("%d",m_sticks);
	m_StickView.SetWindowText(s);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CSetGame::OnReleasedcaptureSticks(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	m_sticks=m_Stick.GetPos();
	CString s;
	s.Format("%d",m_sticks);
	m_StickView.SetWindowText(s);

	*pResult = 0;
}

HBRUSH CSetGame::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
	
	// TODO: Change any attributes of the DC here
	if(pWnd->m_hWnd==m_ColorBox.m_hWnd)
	{
		static HBRUSH hbrush;
		hbrush=::CreateSolidBrush(m_bkcolor);

		return hbrush;
	}
	// TODO: Return a different brush if the default is not desired
	return hbr;
}

⌨️ 快捷键说明

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