📄 animaldlg.cpp
字号:
// AnimalDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Animal.h"
#include "AnimalDlg.h"
#include "Rule.h"
#include "Dbase.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()
/////////////////////////////////////////////////////////////////////////////
// CAnimalDlg dialog
CAnimalDlg::CAnimalDlg(CWnd* pParent /*=NULL*/)
: CDialog(CAnimalDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CAnimalDlg)
m_bmaofa = FALSE;
m_bmilk = FALSE;
m_byumao = FALSE;
m_bfly = FALSE;
m_begg = FALSE;
m_bmeat = FALSE;
m_bquanchi = FALSE;
m_bzhao = FALSE;
m_beyeforward = FALSE;
m_strresult = _T("");
m_bti = FALSE;
m_bjuefanchu = FALSE;
m_bhuanghe = FALSE;
m_bswim = FALSE;
m_bgoodatfly = FALSE;
m_bblackwhite = FALSE;
m_banban = FALSE;
m_bblackstripe = FALSE;
m_blongsnake = FALSE;
m_blongleg = FALSE;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CAnimalDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAnimalDlg)
DDX_Check(pDX, IDC_CHECK1, m_bmaofa);
DDX_Check(pDX, IDC_CHECK2, m_bmilk);
DDX_Check(pDX, IDC_CHECK3, m_byumao);
DDX_Check(pDX, IDC_CHECK4, m_bfly);
DDX_Check(pDX, IDC_CHECK5, m_begg);
DDX_Check(pDX, IDC_CHECK6, m_bmeat);
DDX_Check(pDX, IDC_CHECK7, m_bquanchi);
DDX_Check(pDX, IDC_CHECK8, m_bzhao);
DDX_Check(pDX, IDC_CHECK9, m_beyeforward);
DDX_Text(pDX, IDC_RESULT, m_strresult);
DDX_Check(pDX, IDC_CHECK10, m_bti);
DDX_Check(pDX, IDC_CHECK11, m_bjuefanchu);
DDX_Check(pDX, IDC_CHECK12, m_bhuanghe);
DDX_Check(pDX, IDC_CHECK17, m_bswim);
DDX_Check(pDX, IDC_CHECK18, m_bgoodatfly);
DDX_Check(pDX, IDC_CHECK19, m_bblackwhite);
DDX_Check(pDX, IDC_CHECK13, m_banban);
DDX_Check(pDX, IDC_CHECK14, m_bblackstripe);
DDX_Check(pDX, IDC_CHECK15, m_blongsnake);
DDX_Check(pDX, IDC_CHECK16, m_blongleg);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAnimalDlg, CDialog)
//{{AFX_MSG_MAP(CAnimalDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_REC, OnRec)
ON_BN_CLICKED(IDC_AGAIN, OnAgain)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAnimalDlg message handlers
BOOL CAnimalDlg::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 CAnimalDlg::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 CAnimalDlg::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();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CAnimalDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CAnimalDlg::OnRec()
{
// TODO: Add your control notification handler code here
this->rule.db.flag=0x000000;
UpdateData(TRUE);
if(this->m_banban==TRUE) this->rule.db.flag|=CDbase::anban;
if(this->m_bblackstripe==TRUE) this->rule.db.flag|=CDbase::blackstripe;
if(this->m_bblackwhite==TRUE) rule.db.flag|=CDbase::blackwhite;
if(this->m_begg==TRUE) rule.db.flag|=CDbase::egg;
if(this->m_beyeforward==TRUE) rule.db.flag|=CDbase::eyeforward;
if(this->m_bfly==TRUE) rule.db.flag|=CDbase::fly;
if(this->m_bgoodatfly==TRUE) rule.db.flag|=CDbase::goodatfly;
if(this->m_bhuanghe==TRUE) rule.db.flag|=CDbase::huanghe;
if(this->m_bjuefanchu==TRUE) rule.db.flag|=CDbase::juefanchu;
if(this->m_blongleg==TRUE) rule.db.flag|=CDbase::longleg;
if(this->m_blongsnake==TRUE) rule.db.flag|=CDbase::longsnake;
if(this->m_bmaofa==TRUE) rule.db.flag|=CDbase::maofa;
if(this->m_bmeat==TRUE) rule.db.flag|=CDbase::meat;
if(this->m_bmilk==TRUE) rule.db.flag|=CDbase::milk;
if(this->m_bquanchi==TRUE) rule.db.flag|=CDbase::quanchi;
if(this->m_bswim==TRUE) rule.db.flag|=CDbase::swim;
if(this->m_bti==TRUE) rule.db.flag|=CDbase::ti;
if(this->m_byumao==TRUE) rule.db.flag|=CDbase::yumao;
if(this->m_bzhao==TRUE) rule.db.flag|=CDbase::zhao;
this->rule.GuiZe();
if(rule.IsBao()) this->m_strresult="金钱豹";
else if(rule.IsTiger()) this->m_strresult="虎";
else if(rule.IsChangJingLu()) this->m_strresult="长颈鹿";
else if(rule.IsBanMa()) this->m_strresult="斑马";
else if(rule.IsTuoNiao()) this->m_strresult="鸵鸟";
else if(rule.IsQiE()) this->m_strresult="企鹅";
else if(rule.IsXinTianWeng()) this->m_strresult="信天翁";
else this->m_strresult="没有您要找的动物";
UpdateData(FALSE);
}
void CAnimalDlg::OnAgain()
{
// TODO: Add your control notification handler code here
m_banban=FALSE;
m_bblackstripe=FALSE;
m_bblackwhite=FALSE;
m_begg=FALSE;
m_beyeforward=FALSE;
m_bfly=FALSE;
m_bgoodatfly=FALSE;
m_bhuanghe=FALSE;
m_bjuefanchu=FALSE;
m_blongleg=FALSE;
m_blongsnake=FALSE;
m_bmaofa=FALSE;
m_bmeat=FALSE;
m_bmilk=FALSE;
m_bquanchi=FALSE;
m_bswim=FALSE;
m_bti=FALSE;
m_byumao=FALSE;
m_bzhao=FALSE;
UpdateData(FALSE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -