📄
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0086)http://www.vchome.net/myforum/viewtheme.asp?area=25&lstsort=0&lstday=-1&page=1&id=8963 -->
<HTML><HEAD><TITLE>查看主题 - 计算器完整代码-中科学管理干部学院 - 编程论坛</TITLE>
<META content=zh-cn http-equiv=Content-Language>
<META content="text/html; charset=gb2312" http-equiv=Content-Type><LINK
href="查看主题 - 计算器完整代码-中科学管理干部学院 - 编程论坛.files/main.css" rel=stylesheet
type=text/css>
<META content="MSHTML 5.00.3831.1800" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff><FONT size=2><FONT size=2>
<SCRIPT language=JavaScript src="" type=text/javascript></SCRIPT>
<CENTER><!-- Header --></FONT>
<TABLE border=0 cellSpacing=0 width=760>
<TBODY>
<TR>
<TD width="43%"><FONT size=2><IMG height=60
src="查看主题 - 计算器完整代码-中科学管理干部学院 - 编程论坛.files/main1.png" width=180></FONT></TD>
<TD align=left vAlign=top width="57%"><FONT size=2><IMG align=top border=0
height=17 src="查看主题 - 计算器完整代码-中科学管理干部学院 - 编程论坛.files/f_root.gif"
width=63><A
href="http://www.vchome.net/myforum/index.asp">论坛首页</A><BR><IMG align=top
border=0 height=16 src="查看主题 - 计算器完整代码-中科学管理干部学院 - 编程论坛.files/f_theme.gif"
width=81><A
href="http://www.vchome.net/myforum/listtheme.asp?area=25&lstsort=0&lstday=-1&page=1">编程论坛</A><BR><IMG
align=top border=0 height=17
src="查看主题 - 计算器完整代码-中科学管理干部学院 - 编程论坛.files/f_content.gif"
width=93>计算器完整代码-中科学管理干部学院 </FONT></TD></TR>
<TR>
<TD width="43%"></TD>
<TD align=right width="57%"><FONT size=2><A
href="http://www.vchome.net/myforum/write.asp?area=25&Parentid=-1"><IMG
alt=发新文章 border=0
src="查看主题 - 计算器完整代码-中科学管理干部学院 - 编程论坛.files/b_newtheme.gif"></A> <A
href="http://www.vchome.net/myforum/write.asp?area=25&Parentid=8963"><IMG
alt=回复主题 border=0
src="查看主题 - 计算器完整代码-中科学管理干部学院 - 编程论坛.files/b_reply.gif"></A>
</FONT></TD></TR></TBODY></TABLE><FONT size=2><!-- the 1st block --></FONT>
<DIV align=center>
<CENTER>
<TABLE bgColor=#c0c0c0 border=0 cellSpacing=1 height=26 width=760>
<TBODY>
<TR bgColor=#cccccc>
<TD height=22 width=146><FONT size=2><B><FONT color=#000000>作
者:</FONT></B></FONT></TD>
<TD height=22 width=600><FONT size=2><B><FONT color=#000000><IMG border=0
src="查看主题 - 计算器完整代码-中科学管理干部学院 - 编程论坛.files/f000.gif">
计算器完整代码-中科学管理干部学院</A> <IMG alt=热门主题 border=0
src="查看主题 - 计算器完整代码-中科学管理干部学院 - 编程论坛.files/hot.gif">
</FONT></B></FONT></TD></TR></TBODY></TABLE></CENTER></DIV><FONT size=2><!-- the 2nd block --></FONT>
<DIV align=center>
<CENTER>
<TABLE bgColor=#c0c0c0 border=0 cellSpacing=1 width=760>
<TBODY>
<TR>
<TD bgColor=#f5f5f5 vAlign=top width=146><FONT size=2><A
href="http://www.vchome.net/myforum/viewinfo.asp?uid=wanghuan"><B>wanghuan</B>
</A><BR><IMG border=0
src="查看主题 - 计算器完整代码-中科学管理干部学院 - 编程论坛.files/level1.gif">
<P> <IMG border=0
src="查看主题 - 计算器完整代码-中科学管理干部学院 - 编程论坛.files/001.gif"> </FONT>
<P></P></TD>
<TD bgColor=#f5f5f5 vAlign=bottom width=600><FONT size=2><BR>// 计算器Dlg.cpp
: implementation
file<BR>/**********************************************************************<BR>
此计算器为一个简单计算器,具有加、减、乘、除、取余、求平方根<BR>" 六种运算功能,可按优先级高低计算结果,遗憾的是,只最大整数为<BR>"
999999999,精度为15位,望以后有所改进。<BR>***********************************************************************/<BR><BR>#include
"stdafx.h"<BR>#include "计算器.h"<BR>#include "计算器Dlg.h"<BR>#include
<stdlib.h><BR>#include <math.h><BR>#include
<string.h><BR>#include "Counter.h"<BR><BR><BR>#ifdef
_DEBUG<BR>#define new DEBUG_NEW<BR>#undef THIS_FILE<BR>static char
THIS_FILE[] =
__FILE__;<BR>#endif<BR><BR>/////////////////////////////////////////////////////////////////////////////<BR>//
CAboutDlg dialog used for App About<BR><BR>class CAboutDlg : public
CDialog<BR>{<BR>public:<BR>"CAboutDlg();<BR><BR>// Dialog
Data<BR>"//{{AFX_DATA(CAboutDlg)<BR>"enum { IDD = IDD_ABOUTBOX
};<BR>"//}}AFX_DATA<BR><BR>"// ClassWizard generated virtual function
overrides<BR>"//{{AFX_VIRTUAL(CAboutDlg)<BR>"protected:<BR>"virtual void
DoDataExchange(CDataExchange* pDX); // DDX/DDV
support<BR>"//}}AFX_VIRTUAL<BR><BR>//
Implementation<BR>protected:<BR>"//{{AFX_MSG(CAboutDlg)<BR>"//}}AFX_MSG<BR>"DECLARE_MESSAGE_MAP()<BR>};<BR><BR>CAboutDlg::CAboutDlg()
:
CDialog(CAboutDlg::IDD)<BR>{<BR>"//{{AFX_DATA_INIT(CAboutDlg)<BR>"//}}AFX_DATA_INIT<BR>}<BR><BR>void
CAboutDlg::DoDataExchange(CDataExchange*
pDX)<BR>{<BR>"CDialog::DoDataExchange(pDX);<BR>"//{{AFX_DATA_MAP(CAboutDlg)<BR>"//}}AFX_DATA_MAP<BR>}<BR><BR>BEGIN_MESSAGE_MAP(CAboutDlg,
CDialog)<BR>"//{{AFX_MSG_MAP(CAboutDlg)<BR>""// No message
handlers<BR>"//}}AFX_MSG_MAP<BR>END_MESSAGE_MAP()<BR><BR>/////////////////////////////////////////////////////////////////////////////<BR>//
CMyDlg dialog<BR><BR>CMyDlg::CMyDlg(CWnd* pParent /*=NULL*/)<BR>":
CDialog(CMyDlg::IDD,
pParent)<BR>{<BR>"//{{AFX_DATA_INIT(CMyDlg)<BR>"m_memory = _T("
");<BR>"m_show = 0.0;<BR>"//}}AFX_DATA_INIT<BR>"// Note that LoadIcon does
not require a subsequent DestroyIcon in Win32<BR>"m_hIcon =
AfxGetApp()->LoadIcon(SC);<BR>}<BR><BR>void
CMyDlg::DoDataExchange(CDataExchange*
pDX)<BR>{<BR>"CDialog::DoDataExchange(pDX);<BR>"//{{AFX_DATA_MAP(CMyDlg)<BR>"DDX_Text(pDX,
IDC_EDIT2, m_memory);<BR>"DDX_Text(pDX, IDC_EDIT1,
m_show);<BR>"//}}AFX_DATA_MAP<BR>}<BR><BR>BEGIN_MESSAGE_MAP(CMyDlg,
CDialog)<BR>"//{{AFX_MSG_MAP(CMyDlg)<BR>"ON_WM_SYSCOMMAND()<BR>"ON_WM_PAINT()<BR>"ON_WM_QUERYDRAGICON()<BR>"ON_EN_CHANGE(IDC_EDIT1,
OnChangeEdit1)<BR>"ON_EN_CHANGE(IDC_EDIT2,
OnChangeEdit2)<BR>"ON_BN_CLICKED(IDC_BUTTON1,
OnButton1)<BR>"ON_BN_CLICKED(IDC_BUTTON2,
OnButton2)<BR>"ON_BN_CLICKED(IDC_BUTTON3,
OnButton3)<BR>"ON_BN_CLICKED(IDC_BUTTON4,
OnButton4)<BR>"ON_BN_CLICKED(IDC_BUTTON5,
OnButton5)<BR>"ON_BN_CLICKED(IDC_BUTTON6,
OnButton6)<BR>"ON_BN_CLICKED(IDC_BUTTON7,
OnButton7)<BR>"ON_BN_CLICKED(IDC_BUTTON8,
OnButton8)<BR>"ON_BN_CLICKED(IDC_BUTTON9,
OnButton9)<BR>"ON_BN_CLICKED(IDC_BUTTON10,
OnButton10)<BR>"ON_BN_CLICKED(IDC_BUTTON11,
OnButton11)<BR>"ON_BN_CLICKED(IDC_BUTTON16,
OnButton16)<BR>"ON_BN_CLICKED(IDC_BUTTON17,
OnButton17)<BR>"ON_BN_CLICKED(IDC_BUTTON18,
OnButton18)<BR>"ON_BN_CLICKED(IDC_BUTTON19,
OnButton19)<BR>"ON_BN_CLICKED(IDC_BUTTON24,
OnButton24)<BR>"ON_BN_CLICKED(IDC_BUTTON25,
OnButton25)<BR>"ON_BN_CLICKED(IDC_BUTTON26,
OnButton26)<BR>"ON_BN_CLICKED(IDC_BUTTON27,
OnButton27)<BR>"ON_BN_CLICKED(IDC_BUTTON20,
OnButton20)<BR>"ON_BN_CLICKED(IDC_BUTTON21,
OnButton21)<BR>"ON_BN_CLICKED(IDC_BUTTON22,
OnButton22)<BR>"ON_BN_CLICKED(IDC_BUTTON23,
OnButton23)<BR>"ON_BN_CLICKED(IDC_BUTTON12,
OnButton12)<BR>"ON_BN_CLICKED(IDC_BUTTON13,
OnButton13)<BR>"ON_BN_CLICKED(IDC_BUTTON14,
OnButton14)<BR>"ON_BN_CLICKED(IDC_BUTTON15, OnButton15)<BR>
<BR>"//}}AFX_MSG_MAP<BR>END_MESSAGE_MAP()<BR><BR>/////////////////////////////////////////////////////////////////////////////<BR>//
CMyDlg message handlers<BR><BR>BOOL
CMyDlg::OnInitDialog()<BR>{<BR>"CDialog::OnInitDialog();<BR><BR>"// Add
"About..." menu item to system menu.<BR><BR>"// IDM_ABOUTBOX must be in
the system command range.<BR>"ASSERT((IDM_ABOUTBOX & 0xFFF0) ==
IDM_ABOUTBOX);<BR>"ASSERT(IDM_ABOUTBOX < 0xF000);<BR><BR>"CMenu*
pSysMenu = GetSystemMenu(FALSE);<BR>"if (pSysMenu !=
NULL)<BR>"{<BR>""CString
strAboutMenu;<BR>""strAboutMenu.LoadString(IDS_ABOUTBOX);<BR>""if
(!strAboutMenu.IsEmpty())<BR>""{<BR>"""pSysMenu->AppendMenu(MF_SEPARATOR);<BR>"""pSysMenu->AppendMenu(MF_STRING,
IDM_ABOUTBOX, strAboutMenu);<BR>""}<BR>"}<BR><BR>"// Set the icon for this
dialog. The framework does this automatically<BR>"// when the
application's main window is not a dialog<BR>"SetIcon(m_hIcon, TRUE);"""//
Set big icon<BR>"SetIcon(m_hIcon, FALSE);""// Set small icon<BR>"<BR>"//
TODO: Add extra initialization here<BR>"<BR>"return TRUE; // return
TRUE unless you set the focus to a control<BR>}<BR><BR>void
CMyDlg::OnSysCommand(UINT nID, LPARAM lParam)<BR>{<BR>"if ((nID &
0xFFF0) == IDM_ABOUTBOX)<BR>"{<BR>""CAboutDlg
dlgAbout;<BR>""dlgAbout.DoModal();<BR>"}<BR>"else<BR>"{<BR>""CDialog::OnSysCommand(nID,
lParam);<BR>"}<BR>}<BR><BR>// If you add a minimize button to your dialog,
you will need the code below<BR>// to draw the icon. For MFC applications
using the document/view model,<BR>// this is automatically done for you by
the framework.<BR><BR>void CMyDlg::OnPaint() <BR>{<BR>"if
(IsIconic())<BR>"{<BR>""CPaintDC dc(this); // device context for
painting<BR><BR>""SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(),
0);<BR><BR>""// Center icon in client rectangle<BR>""int cxIcon =
GetSystemMetrics(SM_CXICON);<BR>""int cyIcon =
GetSystemMetrics(SM_CYICON);<BR>""CRect
rect;<BR>""GetClientRect(&rect);<BR>""int x = (rect.Width() - cxIcon +
1) / 2;<BR>""int y = (rect.Height() - cyIcon + 1) / 2;<BR><BR>""// Draw
the icon<BR>""dc.DrawIcon(x, y,
m_hIcon);<BR>"}<BR>"else<BR>"{<BR>""CDialog::OnPaint();<BR>"}<BR>}<BR><BR>//
The system calls this to obtain the cursor to display while the user
drags<BR>// the minimized window.<BR>HCURSOR
CMyDlg::OnQueryDragIcon()<BR>{<BR>"return (HCURSOR)
m_hIcon;<BR>}<BR><BR>void CMyDlg::OnChangeEdit1() //显示区<BR>{<BR>"// TODO:
Add your control notification handler code here<BR>}<BR><BR>void
CMyDlg::OnChangeEdit2() //存储区<BR>{<BR>"// TODO: Add your control
notification handler code here<BR>}<BR><BR>void CMyDlg::OnButton1() //对
backspace 的处理<BR>{<BR><BR>"if (decimal == 1 && DecimalBit
!= 0) //小数部分<BR>"{<BR>""subscript2--;<BR>""DecimalPart = pow(10,(-1) *
DecimalBit) * (num1[subscript2]-'0');<BR>""m_show = m_show -
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -