//ChessDlg. CPP: implementation file
//
# include "stdafx. H"
# include "Chess. H"
# include "ChessDlg. H"
# ifdef _DEBUG
# define new DEBUG_NEW
# undef THIS_FILE
The static char THIS_FILE []=__FILE__;
# endif
/////////////////////////////////////////////////////////////////////////////
//CAboutDlg dialog informs the for App About
The 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 * symbol;//(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 * symbol)
{
CDialog: : DoDataExchange (symbol);
//{{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 ()
/////////////////////////////////////////////////////////////////////////////
//CChessDlg dialog
CChessDlg: : CChessDlg (pParent/*=NULL CWnd * */)
: CDialog (CChessDlg: : IDD, pParent)
{
//{{AFX_DATA_INIT (CChessDlg)
//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 () - & gt; LoadIcon (IDR_MAINFRAME);
}
Void CChessDlg: : DoDataExchange (CDataExchange * symbol)
{
CDialog: : DoDataExchange (symbol);
//{{AFX_DATA_MAP (CChessDlg)
//NOTE: the ClassWizard will add DDX and DDV calls here
//}} AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP (CChessDlg CDialog)
//{{AFX_MSG_MAP (CChessDlg)
ON_WM_SYSCOMMAND ()
ON_WM_PAINT ()
ON_WM_QUERYDRAGICON ()
ON_BN_CLICKED (IDC_BUT_BEGIN OnButBegin)
ON_BN_CLICKED (IDC_BUT_CLOSE OnButClose)
//}} AFX_MSG_MAP
END_MESSAGE_MAP ()
/////////////////////////////////////////////////////////////////////////////
//CChessDlg message handlers
int CChessDlg: : IntToSubscript (int a)
{
If (a<16 & amp; & A>=48)
The return of 14;
The switch (a)
{
//red pieces
Case 16: return 0;
Case 17:
Case 18: return 1;
Case 19:
Case: 20 return 2;
Case 21:
Case 22: return 3;
Case 23:
Case 24: return 4;
Case 25:
Case: 26 return 5;
Case of 27:
A case of 28:
A case of 29:
A case of 30:
Case 31: return 6;
//black pieces
A case of 32: return 7;
A case of 33:
A case of 34: return 8;
A case of 35:
Case 36: return 9;
Case of 37:
A case of 38: return 10;
Case 39:
Case: 40 return 11;
Case: 41
Case: 42 return 12;
Case: 43
A case of 44:
A case of 45:
A case of 46:
Case: 47 return 13;
Default: the return of 14;
}
}
BOOL CChessDlg: : OnInitDialog ()
{
CDialog: : OnInitDialog ();
//Add "About... "Menu item to system menu.
//IDM_ABOUTBOX must be in the system command range.
ASSERT ((IDM_ABOUTBOX & amp; 0==IDM_ABOUTBOX xfff0));
ASSERT (IDM_ABOUTBOX & lt; 0 xf000);
CMenu * pSysMenu=GetSystemMenu (FALSE);
If (pSysMenu!=NULL)
{
Cstrings strAboutMenu;
StrAboutMenu. LoadString (IDS_ABOUTBOX);
if (! StrAboutMenu. IsEmpty ())
{
PSysMenu - & gt; The AppendMenu (MF_SEPARATOR);
PSysMenu - & gt; 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 the big icon
SetIcon (m_hIcon, FALSE);//Set the small icon
//TODO: Add extra initialization here
//loading board bitmapBITMAP BITMAP.
M_BoardBmp. LoadBitmap (IDB_Chess);
M_BoardBmp. GetBitmap (& amp; BitMap);
M_nBoardWidth=BitMap. BmWidth;
M_nBoardHeight=BitMap. BmHeight;
M_BoardBmp. DeleteObject ();
//load the bitmap pieces
//m_ChessMan. Create (IDB_black_chess, 31 (9, RGB (0128128));
//display board rectangular position
RectBoard. Left=BOARDWIDTH;
RectBoard. Right=BOARDWIDTH + GRILLEWIDTH * 8;
RectBoard. Top=BOARDHEIGHT;
RectBoard. Bottom=BOARDHEIGHT + GRILLEHEIGHT * 8;
InitData ();
Return TRUE;//return TRUE unless you set the focus to a control
}
Void CChessDlg: : OnSysCommand (UINT nID, LPARAM LPARAM)
{
If ((nID & amp; 0 xfff0)==IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
DlgAbout. DoModal ();
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull