📄 liuyf24pointdlg.cpp
字号:
// Liuyf24POINTDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Liuyf24POINT.h"
#include "Liuyf24POINTDlg.h"
#include <iostream.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 void OnAboutbox();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
// 强制重绘
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLiuyf24POINTDlg dialog
CLiuyf24POINTDlg::CLiuyf24POINTDlg(CWnd* pParent /*=NULL*/)
: CDialog(CLiuyf24POINTDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CLiuyf24POINTDlg)
M_PICTURE0 = _T("");
M_PICTURE1 = _T("");
M_PICTURE2 = _T("");
M_PICTURE3 = _T("");
M_EDIT = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CLiuyf24POINTDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CLiuyf24POINTDlg)
DDX_Control(pDX, IDC_PROGRESS1, M_PROGRESS);
DDX_Text(pDX, IDC_PICTURE0, M_PICTURE0);
DDX_Text(pDX, IDC_PICTURE1, M_PICTURE1);
DDX_Text(pDX, IDC_PICTURE2, M_PICTURE2);
DDX_Text(pDX, IDC_PICTURE3, M_PICTURE3);
DDX_Text(pDX, IDC_EDIT1, M_EDIT);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CLiuyf24POINTDlg, CDialog)
//{{AFX_MSG_MAP(CLiuyf24POINTDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1)
ON_BN_CLICKED(IDC_CALC, OnCalc)
ON_BN_CLICKED(IDC_END, OnEnd)
ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
ON_BN_CLICKED(IDC_START, OnStart)
ON_WM_TIMER()
ON_BN_CLICKED(IDC_STATIC10, OnStatic10)
ON_NOTIFY(NM_OUTOFMEMORY, IDC_PROGRESS1, OnOutofmemoryProgress1)
ON_BN_CLICKED(IDC_STATIC11, OnStatic11)
ON_COMMAND(IDD_ABOUTBOX, OnAboutbox)
ON_WM_CTLCOLOR()
ON_EN_CHANGE(IDC_EDIT, OnChangeEdit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLiuyf24POINTDlg message handlers
BOOL CLiuyf24POINTDlg::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
Bitmap[0].LoadBitmap(IDB_BITMAP1);
Bitmap[1].LoadBitmap(IDB_BITMAP2);
Bitmap[2].LoadBitmap(IDB_BITMAP3);
Bitmap[3].LoadBitmap(IDB_BITMAP4);
Bitmap[4].LoadBitmap(IDB_BITMAP5);
Bitmap[5].LoadBitmap(IDB_BITMAP6);
Bitmap[6].LoadBitmap(IDB_BITMAP7);
Bitmap[7].LoadBitmap(IDB_BITMAP8);
Bitmap[8].LoadBitmap(IDB_BITMAP9);
Bitmap[9].LoadBitmap(IDB_BITMAP10);
Bitmap[10].LoadBitmap(IDB_BITMAP11);
Bitmap[11].LoadBitmap(IDB_BITMAP12);
Bitmap[12].LoadBitmap(IDB_BITMAP13);//初始化图案
CProgressCtrl*M_PROGRESS=(CProgressCtrl*)GetDlgItem(IDC_PROGRESS1);
M_PROGRESS->SetRange(0,30);
M_PROGRESS->SetPos(0);
//初始化进度条
SetDlgItemText(IDC_STATIC11,"0分");
m_Score=0;
hAccel=::LoadAccelerators(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDC_START));
return TRUE; // return TRUE unless you set the focus to a control
}
void CLiuyf24POINTDlg::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 CLiuyf24POINTDlg::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 CLiuyf24POINTDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
//以下开始验算
int CLiuyf24POINTDlg::LastPos(CString Str)
{
int SubPos=Str.ReverseFind('-')+1;
int PluPos=Str.ReverseFind('+')+1;
int MulPos=Str.ReverseFind('*')+1;
int DivPos=Str.ReverseFind('/')+1;
int Pos=SubPos;
if(Pos<PluPos)
Pos=PluPos;
if(Pos<MulPos)
Pos=MulPos;
if(Pos<DivPos)
Pos=DivPos;
return Pos;
}
int CLiuyf24POINTDlg::FirstPos(CString Str)
{
int SubPos=Str.Find('-')+1;
int PluPos=Str.Find('+')+1;
int MulPos=Str.Find('*')+1;
int DivPos=Str.Find('/')+1;
int Pos=200;
if(SubPos==0)
SubPos=200;
if(PluPos==0)
PluPos=200;
if(MulPos==0)
MulPos=200;
if(DivPos==0)
DivPos=200;
if(Pos>SubPos)
Pos=SubPos;
if(Pos>PluPos)
Pos=PluPos;
if(Pos>MulPos)
Pos=MulPos;
if(Pos>DivPos)
Pos=DivPos;
return Pos;
}
char CLiuyf24POINTDlg::FirstF(CString Str)
{
int SubPos=Str.Find('-')+1;
int PluPos=Str.Find('+')+1;
int MulPos=Str.Find('*')+1;
int DivPos=Str.Find('/')+1;
int Pos=200;
if(SubPos==0)
SubPos=200;
if(PluPos==0)
PluPos=200;
if(MulPos==0)
MulPos=200;
if(DivPos==0)
DivPos=200;
if(Pos>SubPos)
Pos=SubPos;
if(Pos>PluPos)
Pos=PluPos;
if(Pos>MulPos)
Pos=MulPos;
if(Pos>DivPos)
Pos=DivPos;
char Result='-';
int tempPos=SubPos;
if(PluPos<tempPos)
{
Result='+';
tempPos=PluPos;
}
if(MulPos<tempPos)
{
Result='*';
tempPos=MulPos;
}
if(DivPos<tempPos)
{
Result='/';
tempPos=DivPos;
}
return Result;
}
int CLiuyf24POINTDlg::SubCompute(CString Str)
{
CString Middle=" ";
CString Mul2=" ";
CString Right=" ";
int MulPos=Str.Find('*')+1;
int DivPos=Str.Find('/')+1;
int First=MulPos;
if(MulPos>DivPos)
First=DivPos;
if(DivPos==0&&MulPos!=0)
{
First=MulPos;
DivPos=2000;
}
if(DivPos==0&&MulPos!=0)
{
First=DivPos;
MulPos=2000;
}
while(First)
{
CString tempStr=Str.Mid(0,First-1);
int temp=LastPos(tempStr);
CString Left=Str.Mid(0,temp);
CString Mul1=Str.Mid(temp,First-temp-1);
tempStr=Str.Mid(First,Str.GetLength()-First);
temp=FirstPos(tempStr);
if(temp==200)
{
Mul2=tempStr;
Right=" ";
}
else
{
Mul2=tempStr.Mid(0,temp-1);
Right=tempStr.Mid(temp-1,tempStr.GetLength()-temp+1);
}
if(MulPos>DivPos)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -