MFC计算器主要代码C.docx

上传人:b****3 文档编号:681590 上传时间:2022-10-12 格式:DOCX 页数:24 大小:18.97KB
下载 相关 举报
MFC计算器主要代码C.docx_第1页
第1页 / 共24页
MFC计算器主要代码C.docx_第2页
第2页 / 共24页
MFC计算器主要代码C.docx_第3页
第3页 / 共24页
MFC计算器主要代码C.docx_第4页
第4页 / 共24页
MFC计算器主要代码C.docx_第5页
第5页 / 共24页
点击查看更多>>
下载资源
资源描述

MFC计算器主要代码C.docx

《MFC计算器主要代码C.docx》由会员分享,可在线阅读,更多相关《MFC计算器主要代码C.docx(24页珍藏版)》请在冰豆网上搜索。

MFC计算器主要代码C.docx

MFC计算器主要代码C

//Calculator_17483Dlg.cpp:

implementationfile

//

#include"stdafx.h"

#include"Calculator_17483.h"

#include"Calculator_17483Dlg.h"

#include"afxdialogex.h"

#ifdef_DEBUG

#definenewDEBUG_NEW

#endif

 

//CAboutDlgdialogusedforAppAbout

classCAboutDlg:

publicCDialogEx

{

public:

CAboutDlg();

//DialogData

enum{IDD=IDD_ABOUTBOX};

protected:

virtualvoidDoDataExchange(CDataExchange*pDX);//DDX/DDVsupport

//Implementation

protected:

DECLARE_MESSAGE_MAP()

};

CAboutDlg:

:

CAboutDlg():

CDialogEx(CAboutDlg:

:

IDD)

{

}

voidCAboutDlg:

:

DoDataExchange(CDataExchange*pDX)

{

CDialogEx:

:

DoDataExchange(pDX);

}

BEGIN_MESSAGE_MAP(CAboutDlg,CDialogEx)

END_MESSAGE_MAP()

 

//CCalculator_17483Dlgdialog

 

CCalculator_17483Dlg:

:

CCalculator_17483Dlg(CWnd*pParent/*=NULL*/)

:

CDialogEx(CCalculator_17483Dlg:

:

IDD,pParent)

{

num1=0;

num2=0;

operation=0;

point=0;

nump_1=0;

nump_2=0;

m_hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME);

}

voidCCalculator_17483Dlg:

:

DoDataExchange(CDataExchange*pDX)

{

CDialogEx:

:

DoDataExchange(pDX);

}

BEGIN_MESSAGE_MAP(CCalculator_17483Dlg,CDialogEx)

ON_WM_SYSCOMMAND()

ON_WM_PAINT()

ON_WM_QUERYDRAGICON()

ON_BN_CLICKED(IDC_BUTTON1,&CCalculator_17483Dlg:

:

OnBnClickedButton1)

ON_BN_CLICKED(IDC_BUTTON2,&CCalculator_17483Dlg:

:

OnBnClickedButton2)

ON_BN_CLICKED(IDC_BUTTON3,&CCalculator_17483Dlg:

:

OnBnClickedButton3)

ON_BN_CLICKED(IDC_BUTTON4,&CCalculator_17483Dlg:

:

OnBnClickedButton4)

ON_BN_CLICKED(IDC_BUTTON5,&CCalculator_17483Dlg:

:

OnBnClickedButton5)

ON_BN_CLICKED(IDC_BUTTON6,&CCalculator_17483Dlg:

:

OnBnClickedButton6)

ON_BN_CLICKED(IDC_BUTTON7,&CCalculator_17483Dlg:

:

OnBnClickedButton7)

ON_BN_CLICKED(IDC_BUTTON8,&CCalculator_17483Dlg:

:

OnBnClickedButton8)

ON_BN_CLICKED(IDC_BUTTON9,&CCalculator_17483Dlg:

:

OnBnClickedButton9)

ON_BN_CLICKED(IDC_BUTTON10,&CCalculator_17483Dlg:

:

OnBnClickedButton10)

ON_BN_CLICKED(IDC_BUTTON11,&CCalculator_17483Dlg:

:

OnBnClickedButton11)

ON_BN_CLICKED(IDC_BUTTON12,&CCalculator_17483Dlg:

:

OnBnClickedButton12)

ON_BN_CLICKED(IDC_BUTTON13,&CCalculator_17483Dlg:

:

OnBnClickedButton13)

ON_BN_CLICKED(IDC_BUTTON14,&CCalculator_17483Dlg:

:

OnBnClickedButton14)

ON_BN_CLICKED(IDC_BUTTON15,&CCalculator_17483Dlg:

:

OnBnClickedButton15)

ON_BN_CLICKED(IDC_BUTTON16,&CCalculator_17483Dlg:

:

OnBnClickedButton16)

ON_BN_CLICKED(IDC_BUTTON17,&CCalculator_17483Dlg:

:

OnBnClickedButton17)

END_MESSAGE_MAP()

 

//CCalculator_17483Dlgmessagehandlers

BOOLCCalculator_17483Dlg:

:

OnInitDialog()

{

CDialogEx:

:

OnInitDialog();

//Add"About..."menuitemtosystemmenu.

//IDM_ABOUTBOXmustbeinthesystemcommandrange.

ASSERT((IDM_ABOUTBOX&0xFFF0)==IDM_ABOUTBOX);

ASSERT(IDM_ABOUTBOX<0xF000);

CMenu*pSysMenu=GetSystemMenu(FALSE);

if(pSysMenu!

=NULL)

{

BOOLbNameValid;

CStringstrAboutMenu;

bNameValid=strAboutMenu.LoadString(IDS_ABOUTBOX);

ASSERT(bNameValid);

if(!

strAboutMenu.IsEmpty())

{

pSysMenu->AppendMenu(MF_SEPARATOR);

pSysMenu->AppendMenu(MF_STRING,IDM_ABOUTBOX,strAboutMenu);

}

}

//Settheiconforthisdialog.Theframeworkdoesthisautomatically

//whentheapplication'smainwindowisnotadialog

SetIcon(m_hIcon,TRUE);//Setbigicon

SetIcon(m_hIcon,FALSE);//Setsmallicon

//TODO:

Addextrainitializationhere

returnTRUE;//returnTRUEunlessyousetthefocustoacontrol

}

voidCCalculator_17483Dlg:

:

OnSysCommand(UINTnID,LPARAMlParam)

{

if((nID&0xFFF0)==IDM_ABOUTBOX)

{

CAboutDlgdlgAbout;

dlgAbout.DoModal();

}

else

{

CDialogEx:

:

OnSysCommand(nID,lParam);

}

}

//Ifyouaddaminimizebuttontoyourdialog,youwillneedthecodebelow

//todrawtheicon.ForMFCapplicationsusingthedocument/viewmodel,

//thisisautomaticallydoneforyoubytheframework.

voidCCalculator_17483Dlg:

:

OnPaint()

{

if(IsIconic())

{

CPaintDCdc(this);//devicecontextforpainting

SendMessage(WM_ICONERASEBKGND,reinterpret_cast(dc.GetSafeHdc()),0);

//Centericoninclientrectangle

intcxIcon=GetSystemMetrics(SM_CXICON);

intcyIcon=GetSystemMetrics(SM_CYICON);

CRectrect;

GetClientRect(&rect);

intx=(rect.Width()-cxIcon+1)/2;

inty=(rect.Height()-cyIcon+1)/2;

//Drawtheicon

dc.DrawIcon(x,y,m_hIcon);

}

else

{

CDialogEx:

:

OnPaint();

}

}

//Thesystemcallsthisfunctiontoobtainthecursortodisplaywhiletheuserdrags

//theminimizedwindow.

HCURSORCCalculator_17483Dlg:

:

OnQueryDragIcon()

{

returnstatic_cast(m_hIcon);

}

voidCCalculator_17483Dlg:

:

OnBnClickedButton13()//0

{

if(operation==0){

num1=num1*10+0;

string_num1.Format(_T("%d"),num1);

SetDlgItemTextW(IDC_EDIT1,string_num1);

}

else{

num2=num2*10+0;

string_num2.Format(_T("%d"),num2);

SetDlgItemTextW(IDC_EDIT2,string_num2);

}

//TODO:

Addyourcontrolnotificationhandlerco

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工程科技 > 能源化工

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1