📄 jisuanqidlg.cpp
字号:
// jisuanqiDlg.cpp : implementation file
//
#include "stdafx.h"
#include "jisuanqi.h"
#include "jisuanqiDlg.h"
#include "_guanji.h"
#include "_tuichu.h"
#include "_ai.h"
#include "_date.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CJisuanqiDlg dialog
CJisuanqiDlg::CJisuanqiDlg(CWnd* pParent /*=NULL*/)
: CDialog(CJisuanqiDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CJisuanqiDlg)
m_str2 = _T("");
m_str3 = _T("");
m_ss1 = _T("");
m_ss2 = _T("");
m_str1 = _T("");
t=1;
n=1;
n1=1;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CJisuanqiDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CJisuanqiDlg)
DDX_Control(pDX, IDC_EDIT2, m_edit2);
DDX_Control(pDX, IDC_EDIT5, m_edit5);
DDX_Control(pDX, IDC_EDIT4, m_edit4);
DDX_Control(pDX, IDC_EDIT3, m_edit3);
DDX_Control(pDX, IDC_EDIT1, m_edit1);
DDX_Control(pDX, IDC_BUTTON15, m_jisuan);
DDX_Control(pDX, IDC_BUTTON14, m_s4);
DDX_Control(pDX, IDC_BUTTON13, m_s3);
DDX_Control(pDX, IDC_BUTTON12, m_s2);
DDX_Control(pDX, IDC_BUTTON11, m_s1);
DDX_Control(pDX, IDC_BUTTON10, m_0);
DDX_Control(pDX, IDC_BUTTON9, m_9);
DDX_Control(pDX, IDC_BUTTON8, m_8);
DDX_Control(pDX, IDC_BUTTON7, m_7);
DDX_Control(pDX, IDC_BUTTON6, m_6);
DDX_Control(pDX, IDC_BUTTON5, m_5);
DDX_Control(pDX, IDC_BUTTON4, m_4);
DDX_Control(pDX, IDC_BUTTON3, m_3);
DDX_Control(pDX, IDC_BUTTON2, m_2);
DDX_Control(pDX, IDC_BUTTON1, m_1);
DDX_Text(pDX, IDC_EDIT2, m_str2);
DDX_Text(pDX, IDC_EDIT3, m_str3);
DDX_Text(pDX, IDC_EDIT4, m_ss1);
DDX_Text(pDX, IDC_EDIT5, m_ss2);
DDX_Text(pDX, IDC_EDIT1, m_str1);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CJisuanqiDlg, CDialog)
//{{AFX_MSG_MAP(CJisuanqiDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON11, OnButton11)
ON_BN_CLICKED(IDC_BUTTON12, OnButton12)
ON_BN_CLICKED(IDC_BUTTON13, OnButton13)
ON_BN_CLICKED(IDC_BUTTON14, OnButton14)
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_BUTTON10, OnButton10)
ON_BN_CLICKED(IDC_BUTTON16, OnButton16)
ON_BN_CLICKED(IDC_BUTTON17, OnButton17)
ON_BN_CLICKED(IDC_BUTTON15, OnButton15)
ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1)
ON_EN_CHANGE(IDC_EDIT2, OnChangeEdit2)
ON_BN_CLICKED(IDC_BUTTON18, OnButton18)
ON_EN_HSCROLL(IDC_EDIT1, OnHscrollEdit1)
ON_BN_CLICKED(IDC_BUTTON20, OnButton20)
ON_BN_CLICKED(IDC_BUTTON21, OnButton21)
ON_COMMAND(ID_tuichu, Ontuichu)
ON_COMMAND(ID_shuoming, Onshuoming)
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONDOWN()
ON_EN_KILLFOCUS(IDC_EDIT1, OnKillfocusEdit1)
ON_EN_KILLFOCUS(IDC_EDIT2, OnKillfocusEdit2)
ON_EN_SETFOCUS(IDC_EDIT1, OnSetfocusEdit1)
ON_EN_SETFOCUS(IDC_EDIT2, OnSetfocusEdit2)
ON_BN_CLICKED(IDC_BUTTON19, OnButton19)
ON_BN_CLICKED(IDC_BUTTON22, OnButton22)
ON_EN_SETFOCUS(IDC_EDIT3, OnSetfocusEdit3)
ON_BN_CLICKED(IDC_BUTTON24, OnButton24)
ON_BN_CLICKED(IDC_BUTTON25, OnButton25)
ON_BN_CLICKED(IDC_BUTTON26, OnButton26)
ON_BN_CLICKED(IDC_BUTTON27, OnButton27)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CJisuanqiDlg message handlers
BOOL CJisuanqiDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_edit1.SetFocus();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
// 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 CJisuanqiDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
UpdateData();
m_ss2="Is";
UpdateData(false);
m_str1="";
m_str2="";
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CJisuanqiDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CJisuanqiDlg::OnButton1()
{
// TODO: Add your control notification handler code here
if (t==1)
{
m_str1+="1";
wnd->SetWindowText(m_str1);
}
else if(t==2)
{
m_str2+="1";
wnd->SetWindowText(m_str2);
}
// UpdateData(false);
}
void CJisuanqiDlg::OnButton11()
{
// TODO: Add your control notification handler code here
UpdateData();
m_ss1="+";
UpdateData(false);
m_edit2.SetFocus();
}
void CJisuanqiDlg::OnButton12()
{
// TODO: Add your control notification handler code here
UpdateData();
m_ss1="-";
UpdateData(false);
m_edit2.SetFocus();
}
void CJisuanqiDlg::OnButton13()
{
// TODO: Add your control notification handler code here
UpdateData();
m_ss1="*";
UpdateData(false);
m_edit2.SetFocus();
}
void CJisuanqiDlg::OnButton14()
{
// TODO: Add your control notification handler code here
UpdateData();
m_ss1="÷";
UpdateData(false);
m_edit2.SetFocus();
}
void CJisuanqiDlg::OnButton2()
{
if (t==1)
{
m_str1+="2";
wnd->SetWindowText(m_str1);
}
else if(t==2)
{
m_str2+="2";
wnd->SetWindowText(m_str2);
}
}
void CJisuanqiDlg::OnButton3()
{
// TODO: Add your control notification handler code here
if (t==1)
{
m_str1+="3";
wnd->SetWindowText(m_str1);
}
else if(t==2)
{
m_str2+="3";
wnd->SetWindowText(m_str2);
}
}
void CJisuanqiDlg::OnButton4()
{
// TODO: Add your control notification handler code here
if (t==1)
{
m_str1+="4";
wnd->SetWindowText(m_str1);
}
else if(t==2)
{
m_str2+="4";
wnd->SetWindowText(m_str2);
}
}
void CJisuanqiDlg::OnButton5()
{
// TODO: Add your control notification handler code here
if (t==1)
{
m_str1+="5";
wnd->SetWindowText(m_str1);
}
else if(t==2)
{
m_str2+="5";
wnd->SetWindowText(m_str2);
}
}
void CJisuanqiDlg::OnButton6()
{
// TODO: Add your control notification handler code here
if (t==1)
{
m_str1+="6";
wnd->SetWindowText(m_str1);
}
else if(t==2)
{
m_str2+="6";
wnd->SetWindowText(m_str2);
}
}
void CJisuanqiDlg::OnButton7()
{
// TODO: Add your control notification handler code here
if (t==1)
{
m_str1+="7";
wnd->SetWindowText(m_str1);
}
else if(t==2)
{
m_str2+="7";
wnd->SetWindowText(m_str2);
}
}
void CJisuanqiDlg::OnButton8()
{
// TODO: Add your control notification handler code here
if (t==1)
{
m_str1+="8";
wnd->SetWindowText(m_str1);
}
else if(t==2)
{
m_str2+="8";
wnd->SetWindowText(m_str2);
}
}
void CJisuanqiDlg::OnButton9()
{
// TODO: Add your control notification handler code here
if (t==1)
{
m_str1+="9";
wnd->SetWindowText(m_str1);
}
else if(t==2)
{
m_str2+="9";
wnd->SetWindowText(m_str2);
}
}
void CJisuanqiDlg::OnButton10()
{
// TODO: Add your control notification handler code here
if (t==1)
{
m_str1+="0";
wnd->SetWindowText(m_str1);
}
else if(t==2)
{
m_str2+="0";
wnd->SetWindowText(m_str2);
}
}
void CJisuanqiDlg::OnButton16()
{
// TODO: Add your control notification handler code here
if (t==1)
{
m_str1+=".";
wnd->SetWindowText(m_str1);
}
else if(t==2)
{
m_str2+=".";
wnd->SetWindowText(m_str2);
}
}
void CJisuanqiDlg::OnButton17()
{
// TODO: Add your control notification handler code here
UpdateData();
m_str1="";
m_str2="";
m_str3="";
n=1;
n1=1;
UpdateData(false);
}
void CJisuanqiDlg::OnButton15()
{
// TODO: Add your control notification handler code here
float a,c,d;
char b;
UpdateData();
a=atof(m_str1);
c=atof(m_str2);
if (m_ss1=="+")
{
b='+';
}
if (m_ss1=="-")
{
b='-';
}
if (m_ss1=="*")
{
b='*';
}
if (m_ss1=="÷")
{
b='/';
}
if (m_ss1=="")
{
AfxMessageBox("请选择运算符号",MB_OK);
}
switch(b)
{
case '+':
d=a+c;
UpdateData();
m_str3.Format("%f",d);
UpdateData(false);
break;
case '-':
d=a-c;
UpdateData();
m_str3.Format("%f",d);
UpdateData(false);
break;
case '*':
d=a*c;
UpdateData();
m_str3.Format("%f",d);
UpdateData(false);
break;
case '/':
d=a/c;
UpdateData();
m_str3.Format("%f",d);
UpdateData(false);
break;
}
DWORD dwLength = 100; // 要复制的字串长度
HANDLE hGlobalMemory = GlobalAlloc(GHND, dwLength + 1); // 分配内存
LPBYTE lpGlobalMemory = (LPBYTE)GlobalLock(hGlobalMemory); // 锁定内存
for (int i = 0; i < m_str3.GetLength(); i++) // 将"*"复制到全局内存块
{
*lpGlobalMemory ++= m_str3.GetAt(i);
}
GlobalUnlock(hGlobalMemory); // 锁定内存块解锁
OpenClipboard();
EmptyClipboard();
SetClipboardData(CF_TEXT,hGlobalMemory);
CloseClipboard();
}
void CJisuanqiDlg::OnChangeEdit1()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
UpdateData();
UpdateData(false);
}
void CJisuanqiDlg::OnChangeEdit2()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
UpdateData();
UpdateData(false);
}
void CJisuanqiDlg::OnButton18()
{
// TODO: Add your control notification handler code here
}
void CJisuanqiDlg::OnHscrollEdit1()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function to send the EM_SETEVENTMASK message to the control
// with the ENM_SCROLL flag ORed into the lParam mask.
// TODO: Add your control notification handler code here
// wnd=GetFocus();
}
void CJisuanqiDlg::OnButton20()
{
// TODO: Add your control notification handler code here
if (t==1)
{
m_str1.Delete(m_str1.GetLength()-1,1);
UpdateData(false);
}
if (t==2)
{
m_str2.Delete(m_str2.GetLength()-1,1);
UpdateData(false);
}
}
void CJisuanqiDlg::OnButton21()
{
// TODO: Add your control notification handler code here
system("shutdown -a");
}
void CJisuanqiDlg::OnOK()
{
// TODO: Add extra validation here
C_tuichu tuichu;
tuichu.DoModal();
}
void CJisuanqiDlg::Ontuichu()
{
// TODO: Add your command handler code here
AfxMessageBox("d");
exit(0);
}
void CJisuanqiDlg::Onshuoming()
{
// TODO: Add your command handler code here
C_ai ai;
ai.DoModal();
}
void CJisuanqiDlg::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CDialog::OnMouseMove(nFlags, point);
}
void CJisuanqiDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CDialog::OnLButtonDown(nFlags, point);
}
void CJisuanqiDlg::OnKillfocusEdit1()
{
// TODO: Add your control notification handler code here
// wnd=GetFocus();
}
void CJisuanqiDlg::OnKillfocusEdit2()
{
// TODO: Add your control notification handler code here
// wnd=GetFocus();
}
void CJisuanqiDlg::OnSetfocusEdit1()
{
// TODO: Add your control notification handler code here
t=1;
wnd=GetFocus();
}
void CJisuanqiDlg::OnSetfocusEdit2()
{
// TODO: Add your control notification handler code here
t=2;
wnd=GetFocus();
}
void CJisuanqiDlg::OnButton19()
{
// TODO: Add your control notification handler code here
C_date date;
date.DoModal();
}
void CJisuanqiDlg::OnButton22()
{
// TODO: Add your control notification handler code here
if (t==1)
{
static CString str;
if (n==1)
{
str=m_str1;
wnd->SetWindowText("-"+m_str1);
UpdateData();
}
if (n==-1)
{
m_str1=str;
wnd->SetWindowText(m_str1);
UpdateData();
}
n=n*-1;
}
if (t==2)
{
static CString str;
if (n1==1)
{
str=m_str2;
wnd->SetWindowText("-"+m_str2);
UpdateData();
}
if (n1==-1)
{
m_str2=str;
wnd->SetWindowText(m_str2);
UpdateData();
}
n1=n1*-1;
}
}
void CJisuanqiDlg::OnSetfocusEdit3()
{
// TODO: Add your control notification handler code here
}
void CJisuanqiDlg::OnButton23()
{
// TODO: Add your control notification handler code here
DWORD dwLength = 100; // 要复制的字串长度
HANDLE hGlobalMemory = GlobalAlloc(GHND, dwLength + 1); // 分配内存
LPBYTE lpGlobalMemory = (LPBYTE)GlobalLock(hGlobalMemory); // 锁定内存
for (int i = 0; i < m_str3.GetLength(); i++) // 将"*"复制到全局内存块
{
*lpGlobalMemory ++= m_str3.GetAt(i);
}
GlobalUnlock(hGlobalMemory); // 锁定内存块解锁
OpenClipboard();
EmptyClipboard();
SetClipboardData(CF_TEXT,hGlobalMemory);
AfxMessageBox(m_str3);
CloseClipboard();
}
void CJisuanqiDlg::OnButton24()
{
// TODO: Add your control notification handler code here
ShellExecute(NULL,NULL,"http://www.gaodaxia.com.cn",NULL,NULL,SW_SHOWNORMAL);
}
void CJisuanqiDlg::OnButton25()
{
// TODO: Add your control notification handler code here
ShellExecute(NULL,NULL,"http://bbs.pczoz.cn",NULL,NULL,SW_SHOWNORMAL);
}
void CJisuanqiDlg::OnButton26()
{
// TODO: Add your control notification handler code here
ShellExecute(NULL,NULL,"http://www.google.cn",NULL,NULL,SW_SHOWNORMAL);
}
void CJisuanqiDlg::OnButton27()
{
// TODO: Add your control notification handler code here
AfxMessageBox("制作中");
}
void CJisuanqiDlg::OnCancel()
{
// TODO: Add extra cleanup here
ShellExecute(NULL,NULL,"http://www.baidu.com",NULL,NULL,SW_SHOWNORMAL);
CDialog::OnCancel();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -