// Mfc_CounterDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Mfc_Counter.h"
#include "Mfc_CounterDlg.h"
#include "SkinPlusPlus.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()
/////////////////////////////////////////////////////////////////////////////
// CMfc_CounterDlg dialog
CMfc_CounterDlg::CMfc_CounterDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMfc_CounterDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CMfc_CounterDlg)
m_number = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CMfc_CounterDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMfc_CounterDlg)
DDX_Text(pDX, IDC_EDIT1, m_number);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMfc_CounterDlg, CDialog)
//{{AFX_MSG_MAP(CMfc_CounterDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_ADD, OnAdd)
ON_BN_CLICKED(IDC_MINUS, OnMinus)
ON_BN_CLICKED(IDC_CHU, OnChu)
ON_BN_CLICKED(IDC_AMOUNT, OnAmount)
ON_BN_CLICKED(IDC_RIDE, OnRide)
ON_BN_CLICKED(IDC_EIGHT, OnEight)
ON_BN_CLICKED(IDC_FIVE, OnFive)
ON_BN_CLICKED(IDC_FOUR, OnFour)
ON_BN_CLICKED(IDC_NINE, OnNine)
ON_BN_CLICKED(IDC_ONE, OnOne)
ON_BN_CLICKED(IDC_SEVEN, OnSeven)
ON_BN_CLICKED(IDC_SIX, OnSix)
ON_BN_CLICKED(IDC_THREE, OnThree)
ON_BN_CLICKED(IDC_TWO, OnTwo)
ON_BN_CLICKED(IDC_ZERO, OnZero)
ON_WM_CREATE()
ON_WM_SHOWWINDOW()
ON_BN_CLICKED(IDC_POINT, OnPoint)
ON_BN_CLICKED(IDC_CHU2, OnChu2)
ON_COMMAND(ID_MENUITEM32771, OnMenuitem32771)
ON_COMMAND(ID_MENUITEM32772, OnMenuitem32772)
ON_COMMAND(ID_MENUITEM32773, OnMenuitem32773)
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMfc_CounterDlg message handlers
BOOL CMfc_CounterDlg::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 CMfc_CounterDlg::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 CMfc_CounterDlg::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 CMfc_CounterDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CMfc_CounterDlg::OnOK()
{
// TODO: Add extra validation here
}
void CMfc_CounterDlg::OnAdd()
{
// TODO: Add your control notification handler code here
m_isBtnDown=TRUE; //判断+号是否按下
m_countType='+';
OnAmount() ; //计算结果
}
void CMfc_CounterDlg::OnMinus()
{
// TODO: Add your control notification handler code here
m_isBtnDown=TRUE; //判断-号是否按下
m_countType='-';
OnAmount() ; //计算结果
}
void CMfc_CounterDlg::OnChu()
{
// TODO: Add your control notification handler code here
m_isBtnDown=TRUE; //判断/号是否按下
m_countType='/';
OnAmount() ; //计算结果
}
void CMfc_CounterDlg::OnRide()
{
// TODO: Add your control notification handler code here
m_isBtnDown=TRUE; //判断*号是否按下
m_countType='*';
OnAmount() ; //计算结果
}
void CMfc_CounterDlg::OnEight()
{
OnCount('8'); //是按下那个数字
}
void CMfc_CounterDlg::OnFive()
{
OnCount('5'); //是按下那个数字
}
void CMfc_CounterDlg::OnFour()
{
OnCount('4'); //是按下那个数字
}
void CMfc_CounterDlg::OnNine()
{
OnCount('9'); //是按下那个数字
}
void CMfc_CounterDlg::OnOne()
{
// TODO: Add your control notification handler code here
OnCount('1'); //是按下那个数字
}
void CMfc_CounterDlg::OnSeven()
{
// TODO: Add your control notification handler code here
OnCount('7'); //是按下那个数字
}
void CMfc_CounterDlg::OnSix()
{
// TODO: Add your control notification handler code here
OnCount('6'); //是按下那个数字
}
void CMfc_CounterDlg::OnThree()
{
// TODO: Add your control notification handler code here
OnCount('3'); //是按下那个数字
}
void CMfc_CounterDlg::OnTwo()
{
// TODO: Add your control notification handler code here
OnCount('2'); //是按下那个数字
}
void CMfc_CounterDlg::OnZero()
{
// TODO: Add your control notification handler code here
OnCount('0'); //是按下那个数字
}
void CMfc_CounterDlg::OnAmount()
{
// TODO: Add your control notification handler code here
m_isBtnDown=TRUE; //判断=号是否按下
m_secondNum=atof(m_number);
SetDlgItemText(IDC_EDIT1,m_number);
if(m_countType=='+')
{
m_count.Format("%lf",m_firstNum+m_secondNum);
}
else if(m_countType=='-')
{
if(m_firstNum!=0)
{
m_count.Format("%lf",m_firstNum-m_secondNum);
}
else
{m_firstNum=m_secondNum;
m_count.Format("%lf",m_firstNum);
}
}
else if(m_countType=='*')
{
if(m_firstNum==0)
{
m_firstNum=1;
}
m_count.Format("%lf",m_firstNum*m_secondNum);
}
else if(m_countType=='/')
{ if(m_firstNum==0)
{
m_firstNum=m_secondNum;
m_secondNum=1;
}
if(m_secondNum!=0)
{
m_count.Format("%lf",m_firstNum/m_secondNum);
}
else
{
m_number="被除数不能为0,重新输入!";
UpdateData(FALSE);
}
}
UpdateData(FALSE);
SetDlgItemText(IDC_EDIT1,m_count);
}
void CMfc_CounterDlg::OnCount(char ch) //是按下那个数字
{
if(m_isBtnDown==TRUE ) //如果用户按下了 + - * / 其中一个
{
UpdateData();
m_first
zhishi1.rar_ 计算器_vc 计算器_vc++计算器_计算器_计算器 vc++
版权申诉
175 浏览量
2022-09-14
14:40:33
上传
评论
收藏 3KB RAR 举报
朱moyimi
- 粉丝: 61
- 资源: 1万+
最新资源
- #P0015. 全排列 超级简单
- pta题库答案c语言之排序4统计工龄.zip
- pta题库答案c语言之树结构7堆中的路径.zip
- pta题库答案c语言之树结构3TreeTraversalsAgain.zip
- pta题库答案c语言之树结构2ListLeaves.zip
- pta题库答案c语言之树结构1树的同构.zip
- 基于C++实现民航飞行与地图简易管理系统可执行程序+说明+详细注释.zip
- pta题库答案c语言之复杂度1最大子列和问题.zip
- 三维装箱问题(Three-Dimensional Bin Packing Problem,3D-BPP)是一个经典的组合优化问题
- 以下是一些关于Linux线程同步的基本概念和方法.txt
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈