📄 125dlg.cpp
字号:
// 125Dlg.cpp : implementation file
//
#include "stdafx.h"
#include "125.h"
#include "125Dlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
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
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMy125Dlg dialog
CMy125Dlg::CMy125Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CMy125Dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CMy125Dlg)
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
str="编程中国↓";
}
void CMy125Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMy125Dlg)
DDX_Control(pDX, IDC_QINGLING, m_qingling);
DDX_Control(pDX, IDC_BUTTONjian, m_jian);
DDX_Control(pDX, IDC_BUTTONjia, m_jia);
DDX_Control(pDX, IDC_BUTTONCheng, m_cheng);
DDX_Control(pDX, IDC_BUTTONCDengyu, m_dengyu);
DDX_Control(pDX, IDC_BUTTONCChu, m_chu);
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_Control(pDX, IDC_BUTTON0, m_0);
DDX_Control(pDX, IDC_BCZG, m_bczg);
DDX_Control(pDX, IDC_BC_CN, m_bc_cn);
DDX_Control(pDX, IDC_TXT, m_txt);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMy125Dlg, CDialog)
//{{AFX_MSG_MAP(CMy125Dlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTONjia, OnBUTTONjia)
ON_WM_MOUSEMOVE()
ON_BN_CLICKED(IDC_BUTTON0, OnButton0)
ON_BN_CLICKED(IDC_BC_CN, OnBcCn)
ON_BN_CLICKED(IDC_BCZG, OnBczg)
ON_WM_CTLCOLOR()
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_QINGLING, OnQingling)
ON_BN_CLICKED(IDC_BUTTONjian, OnBUTTONjian)
ON_BN_CLICKED(IDC_BUTTONCheng, OnBUTTONCheng)
ON_BN_CLICKED(IDC_BUTTONCChu, OnBUTTONCChu)
ON_BN_CLICKED(IDC_BUTTONCDengyu, OnBUTTONCDengyu)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMy125Dlg message handlers
BOOL CMy125Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
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 application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
SetWindowText("计算器");
::SetWindowPos(this->m_hWnd,HWND_TOP,0,0,141,
207,SWP_NOMOVE);
// TODO: Add extra initialization here
hbitmap=LoadBitmap(AfxGetApp()->m_hInstance,(LPCSTR)IDB_BITMAP1);
::SendDlgItemMessage(this->m_hWnd,IDC_BCZG,
BM_SETIMAGE,IMAGE_BITMAP ,(LPARAM)hbitmap);
sumstr="0";
::SetWindowText(::GetDlgItem(this->m_hWnd,IDC_TXT),sumstr);
//初始化数字
nosum=0;
notmp=0;
sos='?';
return TRUE; // return TRUE unless you set the focus to a control
}
void CMy125Dlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::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 CMy125Dlg::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();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CMy125Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CMy125Dlg::OnBUTTONjia()
{
// TODO: Add your control notification handler code here
GetDlgItemText(IDC_TXT,tmpchar);
notmp=atoi(tmpchar);
if(sos=='?')
nosum=atoi(tmpchar);
switch(sos)
{
case '+':
nosum+=notmp;
sumstr.Format("%d",nosum);
break;
case '-':
nosum-=notmp;
sumstr.Format("%d",nosum);
break;
case '*':
nosum*=notmp;
sumstr.Format("%d",nosum);
break;
case '/':
nosum/=notmp;
sumstr.Format("%d",nosum);
break;
}
SetDlgItemText(IDC_TXT,sumstr);
sumstr="0";
sos='+';
}
void CMy125Dlg::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
//:: SetCursor(LoadCursor(,LPCSTR(IDC_CURSOR1)));
CDialog::OnMouseMove(nFlags, point);
}
void CMy125Dlg::OnButton0()
{
// TODO: Add your control notification handler code here
if(sumstr=="0")
{
SetDlgItemText(IDC_TXT,sumstr);
}
else
{
sumstr+="0";
SetDlgItemText(IDC_TXT,sumstr);
}
}
void CMy125Dlg::OnBcCn()
{
// TODO: Add your control notification handler code here
::GetDlgItemText(this->m_hWnd,IDC_BC_CN,t_char,strlen(t_char));
str=t_char;
if(str=="编程中国↑")
{
::SetWindowPos(this->m_hWnd,HWND_TOP,0,0,141,
207,SWP_NOMOVE);
::SetWindowText(::GetDlgItem(this->m_hWnd,IDC_BC_CN),"编程中国↓");
}
if(str=="编程中国↓")
{
::SetWindowPos(this->m_hWnd,HWND_TOP,0,0,
141,289,SWP_NOMOVE);
::SetWindowText(::GetDlgItem(this->m_hWnd,IDC_BC_CN),"编程中国↑");
}
}
void CMy125Dlg::OnBczg()
{
// TODO: Add your control notification handler code here
::ShellExecute(this->m_hWnd,"open","www.bc-cn.net","","", SW_SHOW );
}
HBRUSH CMy125Dlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(255,255,255));
hbr=CreateSolidBrush(RGB(0,0,0));
// TODO: Return a different brush if the default is not desired
return hbr;
}
void CMy125Dlg::OnButton1()
{
// TODO: Add your control notification handler code here
if(sumstr=="0")
{
sumstr="1";
SetDlgItemText(IDC_TXT,sumstr);
}
else
{
sumstr+="1";
SetDlgItemText(IDC_TXT,sumstr);
}
}
void CMy125Dlg::OnButton2()
{
// TODO: Add your control notification handler code here
if(sumstr=="0")
{
sumstr="2";
SetDlgItemText(IDC_TXT,sumstr);
}
else
{
sumstr+="2";
SetDlgItemText(IDC_TXT,sumstr);
}
}
void CMy125Dlg::OnButton3()
{
// TODO: Add your control notification handler code here
if(sumstr=="0")
{
sumstr="3";
SetDlgItemText(IDC_TXT,sumstr);
}
else
{
sumstr+="3";
SetDlgItemText(IDC_TXT,sumstr);
}
}
void CMy125Dlg::OnButton4()
{
// TODO: Add your control notification handler code here
if(sumstr=="0")
{
sumstr="4";
SetDlgItemText(IDC_TXT,sumstr);
}
else
{
sumstr+="4";
SetDlgItemText(IDC_TXT,sumstr);
}
}
void CMy125Dlg::OnButton5()
{
// TODO: Add your control notification handler code here
if(sumstr=="0")
{
sumstr="5";
SetDlgItemText(IDC_TXT,sumstr);
}
else
{
sumstr+="5";
SetDlgItemText(IDC_TXT,sumstr);
}
}
void CMy125Dlg::OnButton6()
{
// TODO: Add your control notification handler code here
if(sumstr=="0")
{
sumstr="6";
SetDlgItemText(IDC_TXT,sumstr);
}
else
{
sumstr+="6";
SetDlgItemText(IDC_TXT,sumstr);
}
}
void CMy125Dlg::OnButton7()
{
// TODO: Add your control notification handler code here
if(sumstr=="0")
{
sumstr="7";
SetDlgItemText(IDC_TXT,sumstr);
}
else
{
sumstr+="7";
SetDlgItemText(IDC_TXT,sumstr);
}
}
void CMy125Dlg::OnButton8()
{
// TODO: Add your control notification handler code here
if(sumstr=="0")
{
sumstr="8";
SetDlgItemText(IDC_TXT,sumstr);
}
else
{
sumstr+="8";
SetDlgItemText(IDC_TXT,sumstr);
}
}
void CMy125Dlg::OnButton9()
{
// TODO: Add your control notification handler code here
if(sumstr=="0")
{
sumstr="9";
SetDlgItemText(IDC_TXT,sumstr);
}
else
{
sumstr+="9";
SetDlgItemText(IDC_TXT,sumstr);
}
}
void CMy125Dlg::OnQingling()
{
// TODO: Add your control notification handler code here
nosum=0;
sumstr="0";
SetDlgItemText(IDC_TXT,sumstr);
}
void CMy125Dlg::OnBUTTONjian()
{
// TODO: Add your control notification handler code here
GetDlgItemText(IDC_TXT,tmpchar);
notmp=atoi(tmpchar);
if(sos=='?')
nosum=atoi(tmpchar);
switch(sos)
{
case '+':
nosum+=notmp;
sumstr.Format("%d",nosum);
break;
case '-':
nosum-=notmp;
sumstr.Format("%d",nosum);
break;
case '*':
nosum*=notmp;
sumstr.Format("%d",nosum);
break;
case '/':
nosum/=notmp;
sumstr.Format("%d",nosum);
break;
}
SetDlgItemText(IDC_TXT,sumstr);
sumstr="0";
sos='-';
}
void CMy125Dlg::OnBUTTONCheng()
{
// TODO: Add your control notification handler code here
GetDlgItemText(IDC_TXT,tmpchar);
notmp=atoi(tmpchar);
if(sos=='?')
nosum=atoi(tmpchar);
switch(sos)
{
case '+':
nosum+=notmp;
sumstr.Format("%d",nosum);
break;
case '-':
nosum-=notmp;
sumstr.Format("%d",nosum);
break;
case '*':
nosum*=notmp;
sumstr.Format("%d",nosum);
break;
case '/':
nosum/=notmp;
sumstr.Format("%d",nosum);
break;
}
SetDlgItemText(IDC_TXT,sumstr);
sumstr="0";
sos='*';
}
void CMy125Dlg::OnBUTTONCChu()
{
// TODO: Add your control notification handler code here
GetDlgItemText(IDC_TXT,tmpchar);
notmp=atoi(tmpchar);
if(sos=='?')
nosum=atoi(tmpchar);
switch(sos)
{
case '+':
nosum+=notmp;
sumstr.Format("%d",nosum);
break;
case '-':
nosum-=notmp;
sumstr.Format("%d",nosum);
break;
case '*':
nosum*=notmp;
sumstr.Format("%d",nosum);
break;
case '/':
nosum/=notmp;
sumstr.Format("%d",nosum);
break;
}
SetDlgItemText(IDC_TXT,sumstr);
sumstr="0";
sos='/';
}
void CMy125Dlg::OnBUTTONCDengyu()
{
// TODO: Add your control notification handler code here
GetDlgItemText(IDC_TXT,tmpchar);
notmp=atoi(tmpchar);
if(sos=='?')
nosum=atoi(tmpchar);
switch(sos)
{
case '+':
nosum+=notmp;
sumstr.Format("%d",nosum);
break;
case '-':
nosum-=notmp;
sumstr.Format("%d",nosum);
break;
case '*':
nosum*=notmp;
sumstr.Format("%d",nosum);
break;
case '/':
nosum/=notmp;
sumstr.Format("%d",nosum);
break;
}
SetDlgItemText(IDC_TXT,sumstr);
sumstr="0";
sos='?';
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -