用vc++编写计算器问题

赤沐晴子? 2024-05-28 01:11:16
最佳回答
主要程序代码:edit1dlg.cpp文件void cedit1dlg::onchangeadd1() //加数{ // todo: if th** ** a richedit control, the control will not // send th** notification unless you override the cdialog::oninitdialog() // function and call cricheditctrl().seteventmask() // with the enm_change flag ored into the mask. // todo: add your control notification handler code here cedit *edit=(cedit*)getdlgitem(idc_add1); cstring str; edit->getwindowtext(str); int i=atoi(str); if(i==0) **box("请输入数值!");}void cedit1dlg::onok() //确定{ // todo: add extra validation here updatedata(true);// int i=getcheckedradiobutton(idc_radio1,idc_radio4); if(i==idc_radio1) //+ { m_sum=m_add1+m_add2; } if(i==idc_radio2) //- { m_sum=m_add1-m_add2; } if(i==idc_radio3) //* { m_sum=m_add1*m_add2; } if(i==idc_radio4) // / { m_sum=m_add1/m_add2; } if(i==0) { **box("请输入一种运算符"); } updatedata(false);//记住是update是e //cdialog::onok();//此处应删除!!!}void cedit1dlg::onchangeadd2() //被加数{ // todo: if th** ** a richedit control, the control will not // send th** notification unless you override the cdialog::oninitdialog() // function and call cricheditctrl().seteventmask() // with the enm_change flag ored into the mask. // todo: add your control notification handler code here cedit *edit=(cedit*)getdlgitem(idc_add2); cstring str; edit->getwindowtext(str); int i=atoi(str); if(i==0) **box("请输入数值!");}完整程序代码:// edit1dlg.cpp : implementation file//#include "stdafx.h"#include "edit1.h"#include "edit1dlg.h"#ifdef _debug#define new debug_new#undef th**_filestatic char th**_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_**_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_**_map(caboutdlg, cdialog) //{{afx_msg_map(caboutdlg) // no ** handlers //}}afx_msg_mapend_**_map()/////////////////////////////////////////////////////////////////////////////// cedit1dlg dialogcedit1dlg::cedit1dlg(cwnd* pparent /*=***/) : cdialog(cedit1dlg::idd, pparent){ //{{afx_data_init(cedit1dlg) m_add1 = 0.0f; m_add2 = 0.0f; m_sum = 0.0f; //}}afx_data_init // note that loadicon does not require a subsequent destroyicon in win32 m_hicon = afxgetapp()->loadicon(idr_mainframe);}void cedit1dlg::dodataexchange(cdataexchange* pdx){ cdialog::dodataexchange(pdx); //{{afx_data_map(cedit1dlg) ddx_text(pdx, idc_add1, m_add1); ddx_text(pdx, idc_add2, m_add2); ddx_text(pdx, idc_sum, m_sum); //}}afx_data_map}begin_**_map(cedit1dlg, cdialog) //{{afx_msg_map(cedit1dlg) on_wm_syscommand() on_wm_paint() on_wm_querydragicon() on_en_change(idc_add1, onchangeadd1) on_en_change(idc_add2, onchangeadd2) on_en_change(idc_sum, onchangesum) //}}afx_msg_mapend_**_map()/////////////////////////////////////////////////////////////////////////////// cedit1dlg ** handler**ool cedit1dlg::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 != **) { cstring straboutmenu; straboutmenu.loadstring(ids_aboutbox); if (!straboutmenu.**empty()) { psysmenu->appendmenu(mf_separator); psysmenu->appendmenu(mf_string, idm_aboutbox, straboutmenu); } } // set the icon for th** dialog. the framework does th** automatically // when the application's main window ** 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 cedit1dlg::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,// th** ** automatically done for you by the framework.void cedit1dlg::onpaint() { if (**iconic()) { cpaintdc dc(th**); // device context for painting send**(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 th** to obtain the cursor to d**play while the user drags// the minimized window.hcursor cedit1dlg::onquerydragicon(){ return (hcursor) m_hicon;}void cedit1dlg::onchangeadd1() { // todo: if th** ** a richedit control, the control will not // send th** notification unless you override the cdialog::oninitdialog() // function and call cricheditctrl().seteventmask() // with the enm_change flag ored into the mask. // todo: add your control notification handler code here cedit *edit=(cedit*)getdlgitem(idc_add1); cstring str; edit->getwindowtext(str); int i=atoi(str); if(i==0) **box("请输入数值!");}void cedit1dlg::onok() { // todo: add extra validation here updatedata(true);// int i=getcheckedradiobutton(idc_radio1,idc_radio4); if(i==idc_radio1) //+ { m_sum=m_add1+m_add2; } if(i==idc_radio2) //- { m_sum=m_add1-m_add2; } if(i==idc_radio3) //* { m_sum=m_add1*m_add2; } if(i==idc_radio4) // / { m_sum=m_add1/m_add2; } if(i==0) { **box("请输入一种运算符"); } updatedata(false);//记住是update是e //cdialog::onok();//此处应删除!!!}void cedit1dlg::onchangeadd2() { // todo: if th** ** a richedit control, the control will not // send th** notification unless you override the cdialog::oninitdialog() // function and call cricheditctrl().seteventmask() // with the enm_change flag ored into the mask. // todo: add your control notification handler code here cedit *edit=(cedit*)getdlgitem(idc_add2); cstring str; edit->getwindowtext(str); int i=atoi(str); if(i==0) **box("请输入数值!");} 20210311
汇率兑换计算器

类似问答
  • **账单分期计算器用c#怎么编写
    • 2024-05-28 23:34:03
    • 提问者: 未知
    若是,请您登入**官网,点击“理财分期”-“账单分期”,点开后,左边就可以输入金额和期数计算。
  • 请问对于普通的科学计算器,如何编写入计算程序?
    • 2024-05-28 23:26:22
    • 提问者: 未知
    全部程序: 2.二重循环!现在我们想计算 这次我们需要用到5个变量。f记录是否里层循环结束,e标记程序的结束,a、b为循环变量,x为所求的和。首先变量清0 然后计算 由于...
  • 编写一个股票买卖收益计算器
    • 2024-05-28 02:30:50
    • 提问者: 未知
    股票收益即股票投资收益,是指企业或个人以购买股票的形式对外投资取得的股利,转让、出售股票取得款项高于股票帐面实际成本的差额,股权投资在被投资单位增加的净资产中所拥有的数额等。股票收益包括股息收入、资本利得和公积金转增收益。股票收益率是反映股票收益水平的指标 1,是反映投资者以现行...
  • 如何用金融计算器计算ytm?
    • 2024-05-28 01:37:44
    • 提问者: 未知
    你得说下你是什么型号的啊,而且具体题目呢?ytm有很多含义的,可以用来说带日期的债券模型,也可以用来说普通的现金流量tvm或者cf,啥信息也没有,根本没法说啊
  • 建设银行房贷计算器问题?
    • 2024-05-28 02:26:10
    • 提问者: 未知
    我是08年9月购房的,是商业贷房,贷了22w,10年还清,08年每月还2515.5元,不知房贷下调后我现在每月要还多少钱?
  • 大智慧指标编写问题
    • 2024-05-28 07:21:47
    • 提问者: 未知
    你没限制时间啊加上date=xxx之类的条件就行了
  • 用vb编计算器的代码是什么?
    • 2024-05-28 05:59:38
    • 提问者: 未知
    你直接写加减乘除不就行了 给你个加法的例子: 建两个textbox控件,一个label控件,一个commandbutton控件 在commandbutton控件的单击事件写如下代码: ...
  • 一个用c语言调用api函数编写而成的计算器问题,急需解决,求高手指点迷津
    • 2024-05-28 02:07:50
    • 提问者: 未知
    函数名: gcvt功 能: 把浮点数转换成字符串,同时返回一个指向字符串的存储位置的指针。用 法: char *gcvt(double value, int ndigit, char *buf);"gcvt试图以十进制格式产生digits数字,如果不可能,它以指数格式产生digits数字"自己写tostr吧char *tostr(double num){ sprintf(...
  • 用vc++6.0编写一个小软件用于股票交易
    • 2024-05-28 19:49:34
    • 提问者: 未知
    自动交易软件 本人现使用一个“股票下单助手”,是免费的,收费的有“snb,幻影,金牛盯盘,交易开拓者,小闪客,金指南,sd证券自动交易。
  • 博易期货指标-编写问题
    • 2024-05-28 13:13:41
    • 提问者: 未知
    这个简单。回头可以找我给你编写一下,可以远程。
汇率兑换计算器

热门推荐
热门问答
最新问答
推荐问答
新手帮助
常见问题
房贷计算器-九子财经 | 备案号: 桂ICP备19010581号-1 商务联系 企鹅:2790-680461

特别声明:本网为公益网站,人人都可发布,所有内容为会员自行上传发布",本站不承担任何法律责任,如内容有该作者著作权或违规内容,请联系我们清空删除。