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

📄 qiqidlg.cpp

📁 vc++多功能计算器
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// qiqiDlg.cpp : implementation file
//

#include "stdafx.h"
#include "qiqi.h"
#include "qiqiDlg.h"
#include "math.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()

/////////////////////////////////////////////////////////////////////////////
// CQiqiDlg dialog

CQiqiDlg::CQiqiDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CQiqiDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CQiqiDlg)
	m_qq = 0.0;
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CQiqiDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CQiqiDlg)
	DDX_Text(pDX, IDC_EDIT1, m_qq);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CQiqiDlg, CDialog)
	//{{AFX_MSG_MAP(CQiqiDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
	ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
	ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
	ON_BN_CLICKED(IDC_BUTTON6, OnButton6)
	ON_BN_CLICKED(IDC_BUTTON7, OnButton7)
	ON_BN_CLICKED(IDC_BUTTON8, OnButton8)
	ON_BN_CLICKED(IDC_BUTTON9, OnButton9)
	ON_BN_CLICKED(IDC_BUTTON10, OnButton10)
	ON_BN_CLICKED(IDC_BUTTON11, OnButton11)
	ON_BN_CLICKED(IDC_BUTTON12, OnButton12)
	ON_BN_CLICKED(IDC_BUTTON18, OnButton18)
	ON_BN_CLICKED(IDC_BUTTON16, OnButton16)
	ON_BN_CLICKED(IDC_BUTTON14, OnButton14)
	ON_BN_CLICKED(IDC_BUTTON13, OnButton13)
	ON_BN_CLICKED(IDC_BUTTON15, OnButton15)
	ON_BN_CLICKED(IDC_BUTTON17, OnButton17)
	ON_BN_CLICKED(IDC_BUTTON19, OnButton19)
	ON_BN_CLICKED(IDC_BUTTON20, OnButton20)
	ON_BN_CLICKED(IDC_BUTTON21, OnButton21)
	ON_BN_CLICKED(IDC_BUTTON22, OnButton22)
	ON_BN_CLICKED(IDC_BUTTON23, OnButton23)
	ON_BN_CLICKED(IDC_BUTTON24, OnButton24)
	ON_BN_CLICKED(IDC_BUTTON25, OnButton25)
	ON_BN_CLICKED(IDC_BUTTON26, OnButton26)
	ON_BN_CLICKED(IDC_BUTTON27, OnButton27)
	ON_BN_CLICKED(IDC_BUTTON28, OnButton28)
	ON_BN_CLICKED(IDC_BUTTON29, OnButton29)
	ON_BN_CLICKED(IDC_BUTTON31, OnButton31)
	ON_BN_CLICKED(IDC_BUTTON32, OnButton32)
	ON_BN_CLICKED(IDC_BUTTON33, OnButton33)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CQiqiDlg message handlers

BOOL CQiqiDlg::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 CQiqiDlg::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 CQiqiDlg::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 CQiqiDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}



void CQiqiDlg::OnButton1() 
{
	// TODO: Add your control notification handler code here
//	d=1;///这是为Backspace准备的!
	if(b!=false)
	{
	    m_qq=m_qq*10+1;//本程序的核心,至关重要!是实现从编辑框取值的几本要求:如何实现我点击
	               //1,2,3,4,5,6,7,8,9的按钮之后得到的值不被一次一次的刷新!输入完毕后还会被以整体的形式保留;换句话说就是知道是哪个按钮用了	       
                  //m_qq初始值为0.

		         //这只是在整数输入时实用,若是小数则另行方法。
     
	}
	else
	{	
		m_qplay3=m_qq;
		m_qq=0;
		m_qq=m_qplay3+1/pow(10,i);//问题是要知道在按1,2,3,4,5,6,7,8,9这几个按钮时小数点后面已经有几位小数!
			                    //有了在主函数下建立一个累加器即定义一个int型的变量。
                               //代码的意思是1*0.1或0.01.........
		i++;
	}
	UpdateData(false);//这儿的输出与=不同,它是显示我输入值的变化
}
void CQiqiDlg::OnButton2() 
{
	// TODO: Add your control notification handler code here
//	if(m_qq>0)我这样做的时候出错了,原因是我不能保证m_qq是正值,当是负值时就一定会出错,所以系统报错。
//纠正方法是不要将作为判断的值与程序变量混在一起!所以,在定义一个变量来识别是该小数,还是该用整数的方法。
 //  	d=2;///这是为Backspace准备的!
	if(b!=false)
	{
	    m_qq=m_qq*10+2;
	}
	else
	{	
		m_qplay3=m_qq;
		m_qq=0;
		m_qq=m_qplay3+2*1/pow(10,i);
		i++;
	}

   UpdateData(false);
}

void CQiqiDlg::OnButton3() 
{
	// TODO: Add your control notification handler code here
//	d=3;///这是为Backspace准备的!
	if(b!=false)
	{
	    m_qq=m_qq*10+3;
	}
	else
	{	
		m_qplay3=m_qq;
		m_qq=0;
		m_qq=m_qplay3+3*1/pow(10,i);
		i++;
	}

   UpdateData(false);

}

void CQiqiDlg::OnButton4() 
{
	// TODO: Add your control notification handler code here
//	d=4;///这是为Backspace准备的!
	if(b!=false)
	{
	    m_qq=m_qq*10+4;
	}
	else
	{		
		m_qplay3=m_qq;
		m_qq=0;		
		m_qq=m_qplay3+4*1/pow(10,i);
		i++;
	}

   UpdateData(false);
}


void CQiqiDlg::OnButton5() 
{
	// TODO: Add your control notification handler code here
//	d=5;///这是为Backspace准备的!
	if(b!=false)
	{
	    m_qq=m_qq*10+5;
	}
	else
	{
		m_qplay3=m_qq;
		m_qq=0;
		m_qq=m_qplay3+5*1/pow(10,i);
		i++;
	}
   UpdateData(false);

}

void CQiqiDlg::OnButton6() 
{
	// TODO: Add your control notification handler code here
//	d=6;///这是为Backspace准备的!
	if(b!=false)
	{
	    m_qq=m_qq*10+6;
	}
	else
	{	
		m_qplay3=m_qq;
		m_qq=0;
		m_qq=m_qplay3+6*1/pow(10,i);
		i++;
	}

   UpdateData(false);

}

void CQiqiDlg::OnButton7() 
{
	// TODO: Add your control notification handler code here
//	d=7;///这是为Backspace准备的!
	if(b!=false)
	{
	    m_qq=m_qq*10+7;
	}
	else
	{	
		m_qplay3=m_qq;
		m_qq=0;
		m_qq=m_qplay3+7*1/pow(10,i);
		i++;
	}

   UpdateData(false);
}


void CQiqiDlg::OnButton8() 
{
	// TODO: Add your control notification handler code here
//	d=8;///这是为Backspace准备的!
	if(b!=false)
	{
	    m_qq=m_qq*10+8;
	}
	else
	{	
		m_qplay3=m_qq;
		m_qq=0;
		m_qq=m_qplay3+8*1/pow(10,i);
		i++;
	}

   UpdateData(false);

}

void CQiqiDlg::OnButton9() 
{
	// TODO: Add your control notification handler code here
//	d=9;///这是为Backspace准备的!
	if(b!=false)
	{
	    m_qq=m_qq*10+9;

⌨️ 快捷键说明

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