當前位置:編程學習大全網 - 網站源碼 - 使用MFC制作簡單計算器

使用MFC制作簡單計算器

void CCalDlg::OnButtonadd()

{

// TODO: Add your control notification handler code here

UpdateData();

isresult=TRUE;

num1 = m_edit;

m_edit="";

UpdateData(false);

oper=1;

}

void CCalDlg::OnButtondeng()

{

// TODO: Add your control notification handler code here

UpdateData();

num2 = m_edit;

double result=0;

double firnum=atof(num1);

double secnum=atof(num2);

switch(oper)

{case 1:result=firnum+secnum;

m_edit.Format("%g",result);

UpdateData(false);

break;}

}

在使用m_edit前,要先updatedata更新控件內容到變量。

  • 上一篇:使用OD及CE無法附加進程
  • 下一篇:什麽是.net framework 3.5
  • copyright 2024編程學習大全網