📄 mydialog.cpp
字号:
/****************************************************
Author: S. Senthil kumar
File: mydialog.cpp
Purpose: For displaying dialog during pawn promotion
******************************************************/
#include "Global.h"
#include "mydialog.h"
mydialog::mydialog(int n):CDialog(n)
{
}
int mydialog::OnInitDialog()
{
//Generate chess font.
chessfont.CreateFont(27,5,0,0,0,0,0,0,DEFAULT_CHARSET,0,0,0,FF_DECORATIVE,"Chess Merida");
//Create the pieces
pieces[0].Create("p",WS_CHILD|WS_VISIBLE|WS_BORDER|BS_AUTORADIOBUTTON|BS_LEFTTEXT|WS_GROUP,CRect(50,50,100,100),this,1234);
pieces[1].Create("v",WS_CHILD|WS_VISIBLE|WS_BORDER|BS_AUTORADIOBUTTON|BS_LEFTTEXT,CRect(150,50,200,100),this,1235);
pieces[2].Create("m",WS_CHILD|WS_VISIBLE|WS_BORDER|BS_AUTORADIOBUTTON|BS_LEFTTEXT,CRect(250,50,300,100),this,1236);
pieces[3].Create("t",WS_CHILD|WS_VISIBLE|WS_BORDER|BS_AUTORADIOBUTTON|BS_LEFTTEXT,CRect(350,50,400,100),this,1237);
pieces[4].Create("w",WS_CHILD|WS_VISIBLE|WS_BORDER|BS_AUTORADIOBUTTON|BS_LEFTTEXT,CRect(450,50,500,100),this,1238);
groupbox.Create("Select a piece",WS_GROUP|BS_GROUPBOX|WS_CHILD|WS_VISIBLE,CRect(20,30,530,120),this,5);
for (int i=0;i<5;i++)
pieces[i].SetFont(&chessfont);
ok.Create("OK",WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,CRect(250,120,300,150),this,1240);
return CDialog::OnInitDialog();
}
void mydialog::Ok()
{
//Get selected radio button
selectedval=GetCheckedRadioButton(1234,1238);
CDialog::OnOK();
}
int mydialog::GetSelected()
{
//Mod by id and find the correct piece selected.
int val=selectedval%1234;
switch (val)
{
case 0:
return BLACK_PAWN;
case 1:
return BLACK_BISHOP;
case 2:
return BLACK_KNIGHT;
case 3:
return BLACK_ROOK;
case 4:
return BLACK_QUEEN;
}
return 0;
}
BEGIN_MESSAGE_MAP(mydialog,CDialog)
ON_COMMAND(1240,Ok)
END_MESSAGE_MAP()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -