📄 paydlg.cpp
字号:
// PayDlg.cpp : implementation file
//
#include "stdafx.h"
#include "A9410.h"
#include "PayDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPayDlg dialog
CPayDlg::CPayDlg(CWnd* pParent /*=NULL*/)
: CDialog(CPayDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CPayDlg)
m_Pay = 0.0f;
m_Per = 0.0f;
m_Sum = 0.0f;
//}}AFX_DATA_INIT
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CPayDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPayDlg)
DDX_Text(pDX, IDC_EDIT_PAY, m_Pay);
DDX_Text(pDX, IDC_EDIT_PERHOUR, m_Per);
DDV_MinMaxFloat(pDX, m_Per, 0.2f, 1.f);
DDX_Text(pDX, IDC_EDIT_TIMETOTAL, m_Sum);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPayDlg, CDialog)
//{{AFX_MSG_MAP(CPayDlg)
ON_BN_CLICKED(ID_PAY, OnPay)
ON_WM_QUERYDRAGICON()
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPayDlg message handlers
HCURSOR CPayDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CPayDlg::OnPay()
{
// TODO: Add your control notification handler code here
UpdateData();
m_Pay=m_Per*m_Sum;
CString str;
str.Format("%.2f",m_Pay);
if(IDOK==MessageBox("诚惠"+str+"元","交电费",MB_OKCANCEL))
{
m_PayS=true;
CDialog:OnOK();
}
}
BOOL CPayDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
//初始化数据
m_PayS=false;
m_Per=0.68/3;
m_Pay=m_Per*m_Sum;
UpdateData(false);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CPayDlg::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();
}
// TODO: Add your message handler code here
// Do not call CDialog::OnPaint() for painting messages
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -