计算器dlg.cpp

上传人:第*** 文档编号:32827716 上传时间:2018-02-12 格式:DOC 页数:20 大小:91KB
返回 下载 相关 举报
计算器dlg.cpp_第1页
第1页 / 共20页
计算器dlg.cpp_第2页
第2页 / 共20页
计算器dlg.cpp_第3页
第3页 / 共20页
计算器dlg.cpp_第4页
第4页 / 共20页
计算器dlg.cpp_第5页
第5页 / 共20页
点击查看更多>>
资源描述

《计算器dlg.cpp》由会员分享,可在线阅读,更多相关《计算器dlg.cpp(20页珍藏版)》请在金锄头文库上搜索。

1、/ 计算器 Dlg.cpp : implementation file/#include stdafx.h#include 计算器.h#include 计算器 Dlg.h#include math.h#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE = _FILE_;#endif/ CAboutDlg dialog used for App Aboutclass CAboutDlg : public CDialogpublic:CAboutDlg();/ Dialog Data/AFX_DATA(CA

2、boutDlg)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 HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT

3、 nCtlColor);/AFX_MSGDECLARE_MESSAGE_MAP();CAboutDlg:CAboutDlg() : CDialog(CAboutDlg:IDD)/AFX_DATA_INIT(CAboutDlg)/AFX_DATA_INITvoid CAboutDlg:DoDataExchange(CDataExchange* pDX)CDialog:DoDataExchange(pDX);/AFX_DATA_MAP(CAboutDlg)/AFX_DATA_MAPBEGIN_MESSAGE_MAP(CAboutDlg, CDialog)/AFX_MSG_MAP(CAboutDlg

4、)ON_WM_CTLCOLOR()/AFX_MSG_MAPEND_MESSAGE_MAP()/ CMyDlg dialogCMyDlg:CMyDlg(CWnd* pParent /*=NULL*/): CDialog(CMyDlg:IDD, pParent)/AFX_DATA_INIT(CMyDlg)m_Edit = 0.0;/AFX_DATA_INIT/ Note that LoadIcon does not require a subsequent DestroyIcon in Win32m_hIcon = AfxGetApp()-LoadIcon(IDR_MAINFRAME);void

5、CMyDlg:DoDataExchange(CDataExchange* pDX)CDialog:DoDataExchange(pDX);/AFX_DATA_MAP(CMyDlg)DDX_Text(pDX, IDC_EDIT, m_Edit);/AFX_DATA_MAPBEGIN_MESSAGE_MAP(CMyDlg, CDialog)/AFX_MSG_MAP(CMyDlg)ON_WM_SYSCOMMAND()ON_WM_PAINT()ON_WM_QUERYDRAGICON()ON_BN_CLICKED(IDC_BTN7, OnBtn7)ON_BN_CLICKED(IDC_BTN8, OnBt

6、n8)ON_BN_CLICKED(IDC_BTN9, OnBtn9)ON_BN_CLICKED(IDC_BTN4, OnBtn4)ON_BN_CLICKED(IDC_BTN5, OnBtn5)ON_BN_CLICKED(IDC_BTN6, OnBtn6)ON_BN_CLICKED(IDC_BTN1, OnBtn1)ON_BN_CLICKED(IDC_BTN2, OnBtn2)ON_BN_CLICKED(IDC_BTN3, OnBtn3)ON_BN_CLICKED(IDC_BTN10, OnBtn10)ON_BN_CLICKED(IDC_BTN11, OnBtn11)ON_BN_CLICKED(

7、IDC_BTN12, OnBtn12)ON_BN_CLICKED(IDC_BTN13, OnBtn13)ON_BN_CLICKED(IDC_BTN14, OnBtn14)ON_BN_CLICKED(IDC_BTN15, OnBtn15)ON_BN_CLICKED(IDC_BTN17, OnBtn17)ON_BN_CLICKED(IDC_BTN18, OnBtn18)ON_BN_CLICKED(IDC_BTN19, OnBtn19)ON_BN_CLICKED(IDC_BTN16, OnBtn16)ON_BN_CLICKED(IDC_BTN0, OnBtn0)ON_BN_CLICKED(IDC_B

8、TN23, OnBtn23)ON_BN_CLICKED(IDC_BTN24, OnBtn24)ON_BN_CLICKED(IDC_BTN25, OnBtn25)ON_BN_CLICKED(IDC_BTN26, OnBtn26)ON_BN_CLICKED(IDC_BTN27, OnBtn27)ON_BN_CLICKED(IDC_BTN30, OnBtn30)ON_BN_CLICKED(IDC_BTN21, OnBtn21)ON_BN_CLICKED(IDC_BTN22, OnBtn22)ON_BN_CLICKED(IDC_BTN20, OnBtn20)ON_BN_CLICKED(IDC_BTN3

9、2, OnBtn32)ON_COMMAND(ID_jisuanqi, Onjisuanqi)ON_WM_CTLCOLOR()/AFX_MSG_MAPEND_MESSAGE_MAP()/ CMyDlg message handlersBOOL CMyDlg:OnInitDialog()CDialog:OnInitDialog();m_brushBlue.CreateSolidBrush(RGB(0,0,255);/ Add About. menu item to system menu./ IDM_ABOUTBOX must be in the system command range.ASSE

10、RT(IDM_ABOUTBOX 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

11、 does this automatically/ when the applications main window is not a dialogSetIcon(m_hIcon, TRUE); / Set big iconSetIcon(m_hIcon, FALSE); / Set small icon/ TODO: Add extra initialization herem_brush.CreateSolidBrush(RGB(0,255,0);/ greeni =10;t = true;return TRUE; / return TRUE unless you set the foc

12、us to a controlvoid CMyDlg:OnSysCommand(UINT nID, LPARAM lParam)if (nID & 0xFFF0) = IDM_ABOUTBOX)CAboutDlg dlgAbout;dlgAbout.DoModal();elseCDialog: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 d

13、ocument/view model,/ this is automatically done for you by the framework.void CMyDlg:OnPaint() if (IsIconic()CPaintDC dc(this); / device context for paintingSendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);/ Center icon in client rectangleint cxIcon = GetSystemMetrics(SM_CXICON);int cyIco

14、n = GetSystemMetrics(SM_CYICON);CRect rect;GetClientRect(int x = (rect.Width() - cxIcon + 1) / 2;int y = (rect.Height() - cyIcon + 1) / 2;/ Draw the icondc.DrawIcon(x, y, m_hIcon);elseCPaintDC dc(this);CRect rect;GetClientRect(rect);dc.FillSolidRect(rect, RGB(100,150,200);CDialog:OnPaint();/ The sys

15、tem calls this to obtain the cursor to display while the user drags/ the minimized window.HCURSOR CMyDlg:OnQueryDragIcon()return (HCURSOR) m_hIcon;void CMyDlg:OnBtn7() / TODO: Add your control notification handler code hereif(!result)m_Edit=0;result =true;if(t) /如果没有小数点,就要将原数扩大十倍再加 7m_Edit=m_Edit*10+7;UpdateData(FALSE);else

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 建筑/环境 > 工程造价

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号