MFC设计计算机 求助大佬,这程序哪里错了??帮我改改

蒋黎黎 2019-06-01 03:14:30
// jsqDlg.cpp : implementation file//#include "stdafx.h"#include "jsq.h"#include "jsqDlg.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////////////////// CAboutDlg dialog used for App Aboutclass 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// Implementationprotected: //{{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_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// CJsqDlg dialogCJsqDlg::CJsqDlg(CWnd* pParent /*=NULL*/) : CDialog(CJsqDlg::IDD, pParent){ m_display = 0.0; num1 = 0; num2 = 0; result = 0.0; str = " "; str_flag = FALSE; continue_flg = FALSE; downDot = FALSE;count = 1; //{{AFX_DATA_INIT(CJsqDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);}void CJsqDlg::DoDataExchange(CDataExchange* pDX){ CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CJsqDlg) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP(CJsqDlg, CDialog) //{{AFX_MSG_MAP(CJsqDlg) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_BN_CLICKED(IDC_BUTTON_7, OnButton7) ON_BN_CLICKED(IDC_BUTTON_8, OnButton8) ON_BN_CLICKED(IDC_BUTTON_9, OnButton9) ON_BN_CLICKED(IDC_BUTTON_4, OnButton4) ON_BN_CLICKED(IDC_BUTTON_5, OnButton5) ON_BN_CLICKED(IDC_BUTTON_6, OnButton6) ON_BN_CLICKED(IDC_BUTTON_1, OnButton1) ON_BN_CLICKED(IDC_BUTTON_2, OnButton2) ON_BN_CLICKED(IDC_BUTTON_3, OnButton3) ON_BN_CLICKED(IDC_BUTTON_0, OnButton0) ON_BN_CLICKED(IDC_BUTTON_add, OnBUTTONadd) ON_BN_CLICKED(IDC_BUTTON_sub, OnBUTTONsub) ON_BN_CLICKED(IDC_BUTTON_mult, OnBUTTONmult) ON_BN_CLICKED(IDC_BUTTON_div, OnBUTTONdiv) ON_BN_CLICKED(IDC_BUTTON_equal, OnBUTTONequal) ON_BN_CLICKED(IDC_BUTTON_dian, OnBUTTONdian) ON_BN_CLICKED(IDC_BUTTON_c, OnBUTTONc) //}}AFX_MSG_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// CJsqDlg message handlersBOOL CJsqDlg::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 CJsqDlg::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 CJsqDlg::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 CJsqDlg::OnQueryDragIcon(){ return (HCURSOR) m_hIcon;}double CCounterDlg::buttonDownNum(int numSize){ if (!str_flag) //运算符没有被按下,那就是num1{if (!continue_flg) //按下一次{ num1 = numSize; continue_flg =TRUE;} else { num1 = num1*pow(10,count) + numSize; if (downDot){ num1 = num1/(pow(10,count)); count++; } }return num1; } else //有运算符被按下 { if (!continue_flg) //是否连续按下 { num2 = numSize; continue_flg =TRUE; } else { num2 = num2*pow(10,count) + numSize; if (downDot){num2 = num2/(pow(10,count)); count++; } } return num2; }}void CJsqDlg::OnButton7() { // TODO: Add your control notification handler code here m_display=buttonDownNum(0); UpdateData(false); }void CJsqDlg::OnButton8() { // TODO: Add your control notification handler code here m_display=buttonDownNum(8); UpdateData(false); }void CJsqDlg::OnButton9() { // TODO: Add your control notification handler code here m_display=buttonDownNum(9); UpdateData(false); }void CJsqDlg::OnButton4() { // TODO: Add your control notification handler code here m_display=buttonDownNum(4); UpdateData(false); }void CJsqDlg::OnButton5() { // TODO: Add your control notification handler code here m_display=buttonDownNum(5); UpdateData(false); }void CJsqDlg::OnButton6() { // TODO: Add your control notification handler code here m_display=buttonDownNum(6); UpdateData(false);}void CJsqDlg::OnButton1() { // TODO: Add your control notification handler code here m_display=buttonDownNum(1); UpdateData(false);}void CJsqDlg::OnButton2() { // TODO: Add your control notification handler code here m_display=buttonDownNum(2); UpdateData(false);}void CJsqDlg::OnButton3() { // TODO: Add your control notification handler code here m_display=buttonDownNum(3); UpdateData(false);}void CJsqDlg::OnButton0() { // TODO: Add your control notification handler code here m_display=buttonDownNum(0); UpdateData(false);}void CJsqDlg::OnBUTTONadd() { // TODO: Add your control notification handler code here str="+"; str_flag=TRUE; continue_flg=false; doendot=false; count=1; UpdateData(false);}void CJsqDlg::OnBUTTONsub() { // TODO: Add your control notification handler code here str="-"; str_flag=TRUE; continue_flg=false; doendot=false; count=1; UpdateData(false);}void CJsqDlg::OnBUTTONmult() { // TODO: Add your control notification handler code here str="*"; str_flag=TRUE; continue_flg=false; doendot=false; count=1; UpdateData(false);}void CJsqDlg::OnBUTTONdiv() { // TODO: Add your control notification handler code here str="/"; str_flag=TRUE; continue_flg=false; doendot=false; count=1; UpdateData(false);}void CJsqDlg::OnBUTTONequal() { // TODO: Add your control notification handler code hereif(str == "+") result = num1 + num2;else if(str == "-") result = num1 - num2; else if(str == "*") result = num1 * num2; else if(str == "/") { result = double(num1) / double(num2); } num1 = result; m_display = result; str_flag = FALSE; continue_flg = FALSE; downDot = FALSE; count = 1; UpdateData(FALSE);} void CJsqDlg::OnBUTTONdian() { // TODO: Add your control notification handler code here downdian=TRUE;}void CJsqDlg::OnBUTTONc() { // TODO: Add your control notification handler code here num1 = 0;num2 = 0; m_display = 0; continue_flg = FALSE; str_flag = FALSE; downDot = FALSE; count = 1; UpdateData(FALSE);}
...全文
74 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
ooolinux 2019-06-03
  • 打赏
  • 举报
回复
这排版格式,谁看得懂?

1,178

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder 数据库及相关技术
社区管理员
  • 数据库及相关技术社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧