⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testdlg.cpp

📁 一个用 mfc实现的计算器
💻 CPP
字号:
// TestDlg.cpp : implementation file
//

#include "stdafx.h"
#include "计算器.h"
#include "TestDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CTestDlg dialog


CTestDlg::CTestDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CTestDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CTestDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CTestDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CTestDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CTestDlg, CDialog)
	//{{AFX_MSG_MAP(CTestDlg)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
	ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTestDlg message handlers

void CTestDlg::OnButton1() 
{
	// TODO: Add your control notification handler code here
	int num1,num2,num3;
	char ch1[10],ch2[10],ch3[10];
	
	GetDlgItem(IDC_EDIT1)->GetWindowText(ch1,10);
	GetDlgItem(IDC_EDIT2)->GetWindowText(ch2,10);

	num1=atoi(ch1);
	num2=atoi(ch2);
	num3=num1+num2;
	itoa(num3,ch3,10);

	GetDlgItem(IDC_EDIT3)->SetWindowText(ch3);
}

void CTestDlg::OnButton2() 
{
	// TODO: Add your control notification handler code here
	int num1,num2,num3;
	char ch1[10],ch2[10],ch3[10];
	
	GetDlgItem(IDC_EDIT1)->GetWindowText(ch1,10);
	GetDlgItem(IDC_EDIT2)->GetWindowText(ch2,10);

	num1=atoi(ch1);
	num2=atoi(ch2);
	num3=num1-num2;
	itoa(num3,ch3,10);

	GetDlgItem(IDC_EDIT3)->SetWindowText(ch3);
}

void CTestDlg::OnButton3() 
{
	// TODO: Add your control notification handler code here
	int num1,num2,num3;
	char ch1[10],ch2[10],ch3[10];
	
	GetDlgItem(IDC_EDIT1)->GetWindowText(ch1,10);
	GetDlgItem(IDC_EDIT2)->GetWindowText(ch2,10);

	num1=atoi(ch1);
	num2=atoi(ch2);
	num3=num1*num2;
	itoa(num3,ch3,10);

	GetDlgItem(IDC_EDIT3)->SetWindowText(ch3);
}

void CTestDlg::OnButton4() 
{
	// TODO: Add your control notification handler code here
	int num1,num2,num3;
	char ch1[10],ch2[10],ch3[10];
	
	GetDlgItem(IDC_EDIT1)->GetWindowText(ch1,10);
	GetDlgItem(IDC_EDIT2)->GetWindowText(ch2,10);

	num1=atoi(ch1);
	num2=atoi(ch2);
	num3=num1/num2;
	itoa(num3,ch3,10);

	GetDlgItem(IDC_EDIT3)->SetWindowText(ch3);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -