?? 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 + -