📄 animaldlg.cpp
字号:
// animalDlg.cpp : implementation file
//
#include "stdafx.h"
#include "animal.h"
#include "animalDlg.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)
//}}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_Control(pDX, IDC_COMBO9, m_point8);
DDX_Control(pDX, IDC_COMBO10, m_point9);
DDX_Control(pDX, IDC_COMBO11, m_point10);
DDX_Control(pDX, IDC_COMBO8, m_point7);
DDX_Control(pDX, IDC_COMBO7, m_point6);
DDX_Control(pDX, IDC_COMBO6, m_point5);
DDX_Control(pDX, IDC_COMBO5, m_point4);
DDX_Control(pDX, IDC_COMBO4, m_point3);
DDX_Control(pDX, IDC_COMBO3, m_point2);
DDX_Control(pDX, IDC_COMBO2, m_point1);
//}}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_BUTTON1, OnButton_Check)
ON_BN_CLICKED(IDC_BUTTON3, OnButton_Clear)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAnimalDlg message handlers
BOOL CAnimalDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_point1.SetCurSel(0);//设置组合框的默认值为第一项
m_point2.SetCurSel(0);
m_point3.SetCurSel(0);
m_point4.SetCurSel(0);
m_point5.SetCurSel(0);
m_point6.SetCurSel(0);
m_point7.SetCurSel(0);
m_point8.SetCurSel(0);
m_point9.SetCurSel(0);
m_point10.SetCurSel(0);
// 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::OnEditchangeCombo1()
{
// TODO: Add your control notification handler code here
}
void CAnimalDlg::OnEditchangeCombo11()
{
// TODO: Add your control notification handler code here
}
void CAnimalDlg::OnButton_Check()
{
// TODO: Add your control notification handler code here
int i,j,n;
bool check=true;
CString msg="无法判断!";
CString point[10];
m_point1.GetWindowText(point[0]);
m_point2.GetWindowText(point[1]);
m_point3.GetWindowText(point[2]);
m_point4.GetWindowText(point[3]);
m_point5.GetWindowText(point[4]);
m_point6.GetWindowText(point[5]);
m_point7.GetWindowText(point[6]);
m_point8.GetWindowText(point[7]);
m_point9.GetWindowText(point[8]);
m_point10.GetWindowText(point[9]);
for(i=0;i<=8;i++)
{
if(point[i]!="无")
{
for(j=i+1;j<=9;j++)
{
if(point[i]==point[j])
{
check=false;
}
}
}
}
if(check==false)
{
AfxMessageBox("特征不能一样!");
}
else
{
for(i=0;i<=9;i++)//r1
{
if(point[i]=="有毛发")
msg="哺乳动物";
}
for(i=0;i<=9;i++)//r2
{
if(point[i]=="有奶")
msg="哺乳动物";
}
for(i=0;i<=9;i++)//r3
{
if(point[i]=="有羽毛")
msg="鸟";
}
n=0;
for(i=0;i<=9;i++)//r4
{
if(point[i]=="会飞")
{
n++;
}
if(point[i]=="会下蛋")
{
n++;
}
}
if(n==2)
{
msg="鸟";
}
for(i=0;i<=9;i++)//r5
{
if(point[i]=="吃肉")
{
if(msg!="哺乳食肉动物")
{
if(msg=="哺乳动物")
{
msg="哺乳食肉动物";
}
else
{
msg="食肉动物";
}
}
}
}
n=0;//r6
for(i=0;i<=9;i++)
{
if(point[i]=="犬齿")
{
n++;
}
if(point[i]=="有爪")
{
n++;
}
if(point[i]=="眼盯前方")
{
n++;
}
}
if(n==3)
{
if(msg!="哺乳食肉动物")
{
if(msg=="哺乳动物")
{
msg="哺乳食肉动物";
}
else
{
msg="食肉动物";
}
}
}
if(msg=="哺乳动物")//r7
{
for(i=0;i<=9;i++)
{
if(point[i]=="有蹄")
msg="有蹄类动物";
}
}
if(msg=="哺乳动物")//r8
{
for(i=0;i<=9;i++)
{
if(point[i]=="是嚼反诌动物")
msg="有蹄类动物";
}
}
if(msg=="哺乳食肉动物")//r9
{
n=0;
for(i=0;i<=9;i++)
{
if(point[i]=="黄褐色")
{
n++;
}
if(point[i]=="身上有暗斑点")
{
n++;
}
}
if(n==2)
{
msg="金钱豹";
}
}
if(msg=="哺乳食肉动物")//r10
{
n=0;
for(i=0;i<=9;i++)
{
if(point[i]=="黄褐色")
{
n++;
}
if(point[i]=="身上有黑色条纹")
{
n++;
}
}
if(n==2)
{
msg="虎";
}
}
if(msg=="有蹄类动物")//r11
{
n=0;
for(i=0;i<=9;i++)
{
if(point[i]=="有长脖子")
{
n++;
}
if(point[i]=="有长腿")
{
n++;
}
if(point[i]=="身上有暗斑点")
{
n++;
}
}
if(n==3)
{
msg="长颈鹿";
}
}
if(msg=="有蹄类动物")//r12
{
for(i=0;i<=9;i++)
{
if(point[i]=="身上有黑色条纹")
msg="斑马";
}
}
if(msg=="鸟")//r13
{
n=0;
for(i=0;i<=9;i++)
{
if(point[i]=="有长脖子")
{
n++;
}
if(point[i]=="有长腿")
{
n++;
}
if(point[i]=="不会飞")
{
n++;
}
if(point[i]=="有黑白二色")
{
n++;
}
}
if(n==4)
{
msg="鸵鸟";
}
}
if(msg=="鸟")//r14
{
n=0;
for(i=0;i<=9;i++)
{
if(point[i]=="会游泳")
{
n++;
}
if(point[i]=="不会飞")
{
n++;
}
if(point[i]=="有黑白二色")
{
n++;
}
}
if(n==3)
{
msg="企鹅";
}
}
if(msg=="鸟")//r15
{
for(i=0;i<=9;i++)
{
if(point[i]=="善飞")
msg="信天翁";
}
}
AfxMessageBox("此动物为:"+msg);
}
}
void CAnimalDlg::OnButton_Clear()
{
// TODO: Add your control notification handler code here
m_point1.SetCurSel(0);//设置组合框的默认值为第一项
m_point2.SetCurSel(0);
m_point3.SetCurSel(0);
m_point4.SetCurSel(0);
m_point5.SetCurSel(0);
m_point6.SetCurSel(0);
m_point7.SetCurSel(0);
m_point8.SetCurSel(0);
m_point9.SetCurSel(0);
m_point10.SetCurSel(0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -