资源预览内容
第1页 / 共20页
第2页 / 共20页
第3页 / 共20页
第4页 / 共20页
第5页 / 共20页
第6页 / 共20页
第7页 / 共20页
第8页 / 共20页
第9页 / 共20页
第10页 / 共20页
亲,该文档总共20页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
/ 计算器 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(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 HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT 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)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 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, OnBtn8)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(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_BTN23, 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_BTN32, 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.ASSERT(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 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 focus 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 document/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 cyIcon = 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 system 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
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号