計算機程序源代碼_第1頁
計算機程序源代碼_第2頁
計算機程序源代碼_第3頁
計算機程序源代碼_第4頁
計算機程序源代碼_第5頁
已閱讀5頁,還剩22頁未讀 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

計算機程序源代碼

//jisuanqiDlg:implementationfile

//

#include"stdafx.h"

#include"jisuanqi.h"

#include"jisuanqiDlg.h"

#include"math.h"

#ifdef_DEBUG

#definenewDEBUG_NEW

#undefTHIS_FILE

staticcharTHIS_FILE[]=__FILE__;

#endif

/////////////////////////////////////////////////////////////////////////////

//CAboutDlgdialogusedforAppAbout

classCAboutDlg:publicCDialog

{

public:

CAboutDlg();

//DialogData

//{{AFX_DATA(CAboutDlg)

enum{IDD=IDD_ABOUTBOX};

//}}AFX_DATA

//ClassWizardgeneratedvirtualfunctionoverrides

//{{AFX_VIRTUAL(CAboutDlg)

protected:

//DDX/DDV

virtualvoidDoDataExchange(CDataExchange*pDX);

support

//}}AFX_VIRTUAL

//Implementation

protected:

//{{AFX_MSG(CAboutDlg)

//}}AFX_MSG

DECLARE_MESSAGE_MAP()

};

CAboutDlg::CAboutDlg():CDialog(CAboutDlg::IDD)

{

//{{AFX_DATA_INIT(CAboutDlg)

//}}AFX_DATA_INIT

}

voidCAboutDlg::DoDataExchange(CDataExchange*pDX)

{

CDialog::DoDataExchange(pDX);

//{{AFX_DATA_MAP(CAboutDlg)

//}}AFX_DATA_MAP

}

BEGIN_MESSAGE_MAP(CAboutDlg,CDialog)

//{{AFX_MSG_MAP(CAboutDlg)

//Nomessagehandlers

//}}AFX_MSG_MAP

END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////

//CJisuanqiDlgdialog

CJisuanqiDlg::CJisuanqiDlg(CWnd*pParent)

:CDialog(CJisuanqiDlg::IDD,pParent)

{

//{{AFX_DATA_INIT(CJisuanqiDlg)

m_num=0.0;

//}}AFX_DATA_INIT

//NotethatLoadIcondoesnotrequireasubsequentDestroyIconinWin32

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

}

voidCJisuanqiDlg::DoDataExchange(CDataExchange*pDX)

{

CDialog::DoDataExchange(pDX);

//{{AFX_DATA_MAP(CJisuanqiDlg)

DDX_Text(pDX,IDC_EDIT1,m_num);

//}}AFX_DATA_MAP

}

BEGIN_MESSAGE_MAP(CJisuanqiDlg,CDialog)

//{{AFX_MSG_MAP(CJisuanqiDlg)

ON_WM_SYSCOMMAND()

ON_WM_PAINT()

ON_WM_QUERYDRAGICON()ON_BN_CLICKED(IDC_BUTTON1,OnButton1)ON_BN_CLICKED(IDC_BUTTON2,OnButton2)ON_BN_CLICKED(IDC_BUTTON3,OnButton3)ON_BN_CLICKED(IDC_BUTTON4,OnButton4)ON_BN_CLICKED(IDC_BUTTON5,OnButton5)ON_BN_CLICKED(IDC_BUTTON6,OnButton6)ON_BN_CLICKED(IDC_BUTTON7,OnButton7)ON_BN_CLICKED(IDC_BUTTON8,OnButton8)ON_BN_CLICKED(IDC_BUTTON9,OnButton9)ON_BN_CLICKED(IDC_BUTTON14,OnButton0)ON_BN_CLICKED(IDC_BUTTON15,OnButtonPoint)ON_BN_CLICKED(IDC_BUTTON16,OnButtonEqual)ON_BN_CLICKED(IDC_BUTTON13,OnButtonChu)ON_BN_CLICKED(IDC_BUTTON12,OnButtonMul)ON_BN_CLICKED(IDC_BUTTON11,OnButtonSub)ON_BN_CLICKED(IDC_BUTTON10,OnButtonAdd)ON_BN_CLICKED(IDC_BUTTON17,OnButtondelet)ON_BN_CLICKED(IDC_BUTTON18,OnButtonclear)ON_BN_CLICKED(IDC_BUTTON19,OnButtonkaifang)ON_BN_CLICKED(IDC_BUTTON20,OnButtonziranduishu)ON_BN_CLICKED(IDC_BUTTON21,OnButtonchangyongduishu)

//}}AFX_MSG_MAP

END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////

//CJisuanqiDlgmessagehandlers

BOOLCJisuanqiDlg::OnInitDialog()//初始化變量

{

CDialog::OnInitDialog();

//Add"About..."menuitemtosystemmenu.

//IDM_ABOUTBOXmustbeinthesystemcommandrange.ASSERT((IDM_ABOUTBOX&0xFFF0)==IDM_ABOUTBOX);

ASSERT(IDM_ABOUTBOX<0xF000);

CMenu*pSysMenu=GetSystemMenu(FALSE);

if(pSysMenu!=NULL)

{

CStringstrAboutMenu;

strAboutMenu.LoadString(IDS_ABOUTBOX);

if(!strAboutMenu.IsEmpty())

{

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

strAboutMenu);

}

}

//Settheiconforthisdialog.Theframeworkdoesthisautomatically//whentheapplication'smainwindowisnotadialogSetIcon(m_hIcon,TRUE);//Setbigicon

SetIcon(m_hIcon,FALSE);//Setsmallicon

//TODO:Addextrainitializationhere

t=true;

j=true;

i=10;

p=0;

q=0;

m_num=0;

m_lnum=0;

returnTRUE;//returnTRUEunlessyousetthefocustoacontrol}

voidCJisuanqiDlg::OnSysCommand(UINTnID,LPARAMlParam){

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

{

CAboutDlgdlgAbout;

dlgAbout.DoModal();

}

else

{

CDialog::OnSysCommand(nID,lParam);

}

}

//Ifyouaddaminimizebuttontoyourdialog,youwillneedthecodebelow//todrawtheicon.ForMFCapplicationsusingthedocument/viewmodel,//thisisautomaticallydoneforyoubytheframework.

voidCJisuanqiDlg::OnPaint()

{

if(IsIconic())

{

CPaintDCdc(this);//devicecontextforpaintingSendMessage(WM_ICONERASEBKGND,(WPARAM)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

{

CDialog::OnPaint();

}

}

//Thesystemcallsthistoobtainthecursortodisplaywhiletheuserdrags//theminimizedwindow.

HCURSORCJisuanqiDlg::OnQueryDragIcon()

{

return(HCURSOR)m_hIcon;

}

voidCJisuanqiDlg::OnButton1()

{

//TODO:Addyourcontrolnotificationhandlercodehere

if(t)

{

m_num=m_num*10+1;

UpdateData(FALSE);

}

else

{

m_num=m_num+1.0/i;

i*=10;

UpdateData(FALSE);

}

}

voidCJisuanqiDlg::OnButton2()

{

//TODO:Addyourcontrolnotificationhandlercodehere

if(t)

{

m_num=m_num*10+2;

UpdateData(FALSE);

}

else

{

m_num=m_num+2.0/i;

i*=10;

UpdateData(FALSE);

}

}

voidCJisuanqiDlg::OnButton3()

{

//TODO:Addyourcontrolnotificationhandlercodehere

if(t)

{

m_num=m_num*10+3;

UpdateData(FALSE);

}

else

{

m_num=m_num+3.0/i;

i*=10;

UpdateData(FALSE);

}

}

voidCJisuanqiDlg::OnButton4()

{

//TODO:Addyourcontrolnotificationhandlercodehere

if(t)

{

m_num=m_num*10+4;

UpdateData(FALSE);

}

else

{

m_num=m_num+4.0/i;

i*=10;

UpdateData(FALSE);

}

}

voidCJisuanqiDlg::OnButton5()

{

//TODO:Addyourcontrolnotificationhandlercodehere

if(t)

{

m_num=m_num*10+5;

UpdateData(FALSE);

}

else

{

m_num=m_num+5.0/i;

i*=10;

UpdateData(FALSE);

}

}

voidCJisuanqiDlg::OnButton6()

{

//TODO:Addyourcontrolnotificationhandlercodehere

if(t)

{

m_num=m_num*10+6;

UpdateData(FALSE);

}

else

{

m_num=m_num+6.0/i;

i*=10;

UpdateData(FALSE);

}

}

voidCJisuanqiDlg::OnButton7()

{

//TODO:Addyourcontrolnotificationhandlercodehere

if(t)

{

m_num=m_num*10+7;

UpdateData(FALSE);

}

else

{

m_num=m_num+7.0/i;

i*=10;

UpdateData(FALSE);

}

}

voidCJisuanqiDlg::OnButton8()

{

//TODO:Addyourcontrolnotificationhandlercodehere

if(t)

{

m_num=m_num*10+8;

UpdateData(FALSE);

}

else

{

m_num=m_num+8.0/i;

i*=10;

UpdateData(FALSE);

}

}

voidCJisuanqiDlg::OnButton9()

{

//TODO:Addyourcontrolnotificationhandlercodehere

if(t)

{

m_num=m_num*10+9;

UpdateData(FALSE);

}

else

{

m_num=m_num+9.0/i;

i*=10;

UpdateData(FALSE);

}

}

voidCJisuanqiDlg::OnButton0()

{

//TODO:Addyourcontrolnotificationhandlercodehere

//UpdateData();

if(t)

{

m_num=m_num*10+0;

UpdateData(FALSE);

}

else

{

m_num=m_num+0.0/i;

i*=10;

UpdateData(FALSE);

}

}

voidCJisuanqiDlg::OnButtonPoint()

{

//TODO:Addyourcontrolnotificationhandlercodehere

inti=10;

t=false;

}

voidCJisuanqiDlg::OnButtonEqual()

{

//TODO:Addyourcontrolnotificationhandlercodehere

switch(r)

{

case'+':

{

m_num=m_num+m_lnum;

UpdateData(FALSE);

break;

}

case'-':

{

m_num=m_snum-m_num;

UpdateData(FALSE);

break;

}

case'*':

{

m_num=m_mnum*m_num;

UpdateData(FALSE);

break;

}

case'/':

{

if(m_num==0)

{

MessageBox("除數不能是0!");

}

else

{

m_num=m_cnum/m_num;

UpdateData(FALSE);

break;

}

}

}

t=true;

}

voidCJisuanqiDlg::OnButtonMul()

{

//TODO:Addyourcontrolnotificationhandlercodehere

r='*';

t=true;

m_mnum=m_num;

m_num=0;

UpdateData(FALSE);

}

voidCJisuanqiDlg::OnButtonChu()

{

//TODO:Addyourcontrolnotificationhandlercodehere

r='/';

t=true;

i=10;

m_cnum=m_num;

m_num=0;

UpdateData(FALSE);

}

voidCJisuanqiDlg::OnButtonSub()

{

//TODO:Addyourcontrolnotificationhandlercodehere

r='-';

i=10;

t=true;

if(j)

{

m_snum=m_num;

}

else

{

p=0;

adda[p]=m_num;

p++;

for(q=0;q<=p;q++)

{

m_lnum=m_lnum+adda[q];

q++;

}

m_num=m_lnum;

UpdateData(FALSE);

m_num=0;

m_snum=m_lnum;

}

m_num=0;

}

voidCJisuanqiDlg::OnButtonA

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論