www.gusucode.com > 基于MVC的C++五子棋游戏源码源码程序 > 基于MVC的C++五子棋游戏源码源码程序\code\CVSCDlg.cpp
// CVSCDlg.cpp : implementation file // download by http://www.NewXing.com #include "stdafx.h" #include "ms5.h" #include "CVSCDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif int firstgrade = 3; int secondgrade = 3; ///////////////////////////////////////////////////////////////////////////// // CVSCDlg dialog CVSCDlg::CVSCDlg(CWnd* pParent /*=NULL*/) : CDialog(CVSCDlg::IDD, pParent) { //{{AFX_DATA_INIT(CVSCDlg) //}}AFX_DATA_INIT m_import = false; } void CVSCDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CVSCDlg) DDX_Control(pDX, IDC_NOSUBMIT, m_nosubmit); DDX_Control(pDX, IDC_SUBMIT, m_submit); DDX_Control(pDX, IDC_SECONDGRADE, m_secondgrade); DDX_Control(pDX, IDC_FIRSTGRADE, m_firstgrade); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CVSCDlg, CDialog) //{{AFX_MSG_MAP(CVSCDlg) ON_CBN_SELCHANGE(IDC_FIRSTGRADE, OnSelchangeFirstgrade) ON_CBN_SELCHANGE(IDC_SECONDGRADE, OnSelchangeSecondgrade) ON_BN_CLICKED(IDC_SUBMIT, OnSubmit) ON_WM_LBUTTONDOWN() ON_WM_CTLCOLOR() ON_CBN_CLOSEUP(IDC_FIRSTGRADE, OnCloseupFirstgrade) ON_CBN_CLOSEUP(IDC_SECONDGRADE, OnCloseupSecondgrade) ON_BN_CLICKED(IDC_NOSUBMIT, OnNosubmit) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CVSCDlg message handlers BOOL CVSCDlg::OnInitDialog() { CDialog::OnInitDialog(); CString temp; temp.Format("%d",firstgrade); m_firstgrade.SelectString(0,temp); temp.Format("%d",secondgrade); m_secondgrade.SelectString(0,temp); this->CheckRadioButton(IDC_NOIMPORT,IDC_NOIMPORT,IDC_NOIMPORT); m_submit.LoadBitmaps(IDB_BUTTON,5, 5, 5, 5, 4 ); m_nosubmit.LoadBitmaps(IDB_BUTTON,5, 5, 5, 5, 4 ); int i,j; CClientDC dc(this); CBitmap bmp;CDC dcmem;BITMAP bm; bmp.LoadBitmap("bk"); m_brush = CreatePatternBrush((HBITMAP)bmp); GetObject(bmp,sizeof(BITMAP),(LPVOID)&bm); dcmem.CreateCompatibleDC(&dc); dcmem.SelectObject(&bmp); dc.BitBlt(0,0,bm.bmWidth,bm.bmHeight,&dcmem,0,0,SRCCOPY); CRgn myrgn,temprgn; myrgn.CreateRectRgn(0,0,bm.bmWidth,bm.bmHeight); COLORREF color=dcmem.GetPixel(0,0); for(i=0;i<bm.bmWidth;i++) for(j=0;j<bm.bmHeight;j++) { if (dcmem.GetPixel(i,j)==color) { temprgn.CreateRectRgn(i,j,i+1,j+1); myrgn.CombineRgn(&myrgn,&temprgn,RGN_XOR); temprgn.DeleteObject(); } } SetWindowRgn(myrgn,TRUE); bmp.DeleteObject(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CVSCDlg::OnSelchangeFirstgrade() { firstgrade = m_firstgrade.GetCurSel()+1; } void CVSCDlg::OnSelchangeSecondgrade() { secondgrade = m_secondgrade.GetCurSel()+1; } void CVSCDlg::OnSubmit() { if (this->GetCheckedRadioButton(IDC_YESIMPORT,IDC_NOIMPORT)==IDC_YESIMPORT) m_import = true; OnOK(); } void CVSCDlg::OnLButtonDown(UINT nFlags, CPoint point) { SendMessage(WM_SYSCOMMAND,0xf012,0); CDialog::OnLButtonDown(nFlags, point); } HBRUSH CVSCDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); if (nCtlColor==CTLCOLOR_DLG) return m_brush; if (nCtlColor==CTLCOLOR_STATIC) { if (!pWnd->IsKindOf( RUNTIME_CLASS( CEdit ))) { pDC->SetBkMode(TRANSPARENT); return m_brush; } } return hbr; } void CVSCDlg::OnCloseupFirstgrade() { //RedrawWindow(); //UpdateWindow(); } void CVSCDlg::OnCloseupSecondgrade() { //RedrawWindow(); //UpdateWindow(); } void CVSCDlg::OnNosubmit() { OnCancel(); }