📄 caculator03dlg.cpp
字号:
// caculator03Dlg.cpp : implementation file
//
#include "stdafx.h"
#include "caculator03.h"
#include "caculator03Dlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern char Radio;
extern CString strl;
extern int val;
/////////////////////////////////////////////////////////////////////////////
// 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()
/////////////////////////////////////////////////////////////////////////////
// CCaculator03Dlg dialog
CCaculator03Dlg::CCaculator03Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CCaculator03Dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CCaculator03Dlg)
m_InputEdit = _T("");
m_OutputEdit = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CCaculator03Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCaculator03Dlg)
DDX_Control(pDX, IDC_OUTPUT_CHECK, m_OutputCheck);
DDX_Control(pDX, IDC_INPUT_CHECK, m_InputCheck);
DDX_Control(pDX, IDC_F_BUTTON, m_Fbutton);
DDX_Control(pDX, IDC_E_BUTTON, m_Ebutton);
DDX_Control(pDX, IDC_D_BUTTON, m_Dbutton);
DDX_Control(pDX, IDC_C_BUTTON, m_Cbutton);
DDX_Control(pDX, IDC_B_BUTTON, m_Bbutton);
DDX_Control(pDX, IDC_A_BUTTON, m_Abutton);
DDX_Control(pDX, IDC_9_BUTTON, m_9button);
DDX_Control(pDX, IDC_8_BUTTON, m_8button);
DDX_Text(pDX, IDC_INPUTEDIT_EDIT, m_InputEdit);
DDX_Text(pDX, IDC_OUTPUT_EDIT, m_OutputEdit);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCaculator03Dlg, CDialog)
//{{AFX_MSG_MAP(CCaculator03Dlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_D_RADIO, OnDRadio)
ON_BN_CLICKED(IDC_H_RADIO, OnHRadio)
ON_BN_CLICKED(IDC_O_RADIO, OnORadio)
ON_BN_CLICKED(IDC_0_BUTTON, On0Button)
ON_BN_CLICKED(IDC_1_BUTTON, On1Button)
ON_BN_CLICKED(IDC_2_BUTTON, On2Button)
ON_BN_CLICKED(IDC_3_BUTTON, On3Button)
ON_BN_CLICKED(IDC_4_BUTTON, On4Button)
ON_BN_CLICKED(IDC_5_BUTTON, On5Button)
ON_BN_CLICKED(IDC_6_BUTTON, On6Button)
ON_BN_CLICKED(IDC_7_BUTTON, On7Button)
ON_BN_CLICKED(IDC_8_BUTTON, On8Button)
ON_BN_CLICKED(IDC_9_BUTTON, On9Button)
ON_BN_CLICKED(IDC_A_BUTTON, OnAButton)
ON_BN_CLICKED(IDC_B_BUTTON, OnBButton)
ON_BN_CLICKED(IDC_C_BUTTON, OnCButton)
ON_BN_CLICKED(IDC_D_BUTTON, OnDButton)
ON_BN_CLICKED(IDC_E_BUTTON, OnEButton)
ON_BN_CLICKED(IDC_F_BUTTON, OnFButton)
ON_BN_CLICKED(IDC_TO_D_BUTTON, OnToDButton)
ON_BN_CLICKED(IDC_TO_H_BUTTON, OnToHButton)
ON_BN_CLICKED(IDC_TO_O_BUTTON, OnToOButton)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCaculator03Dlg message handlers
BOOL CCaculator03Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
m_Abutton.EnableWindow(FALSE);
m_Bbutton.EnableWindow(FALSE);
m_Cbutton.EnableWindow(FALSE);
m_Dbutton.EnableWindow(FALSE);
m_Ebutton.EnableWindow(FALSE);
m_Fbutton.EnableWindow(FALSE);
// 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
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CCaculator03Dlg::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 CCaculator03Dlg::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 CCaculator03Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CCaculator03Dlg::OnDRadio()
{
// TODO: Add your control notification handler code here
Radio='D';
val=0;
m_Abutton.EnableWindow(FALSE);
m_Bbutton.EnableWindow(FALSE);
m_Cbutton.EnableWindow(FALSE);
m_Dbutton.EnableWindow(FALSE);
m_Ebutton.EnableWindow(FALSE);
m_Fbutton.EnableWindow(FALSE);
}
void CCaculator03Dlg::OnHRadio()
{
// TODO: Add your control notification handler code here
Radio='H';
val=0;
m_8button.EnableWindow(TRUE);
m_9button.EnableWindow(TRUE);
m_Abutton.EnableWindow(TRUE);
m_Bbutton.EnableWindow(TRUE);
m_Cbutton.EnableWindow(TRUE);
m_Dbutton.EnableWindow(TRUE);
m_Ebutton.EnableWindow(TRUE);
m_Fbutton.EnableWindow(TRUE);
}
void CCaculator03Dlg::OnORadio()
{
// TODO: Add your control notification handler code here
Radio='O';
val=0;
m_8button.EnableWindow(FALSE);
m_9button.EnableWindow(FALSE);
m_Abutton.EnableWindow(FALSE);
m_Bbutton.EnableWindow(FALSE);
m_Cbutton.EnableWindow(FALSE);
m_Dbutton.EnableWindow(FALSE);
m_Ebutton.EnableWindow(FALSE);
m_Fbutton.EnableWindow(FALSE);
}
void CCaculator03Dlg::On0Button()
{
// TODO: Add your control notification handler code here
int i_InputCheck=m_InputCheck.GetState();
switch (Radio)
{
case 'O':
val=val*8+0;
strl.Format("%o",val);//将输入的数据转换为字符串
if (i_InputCheck==1) strl=strl+"Q";
break;
case 'D':
val=val*10+0;
strl.Format("%d",val);//将输入的数据转换为字符串
if (i_InputCheck==1) strl=strl+"D";
break;
case 'H':
val=val*16+0;
strl.Format("%x",val);//将输入的数据转换为字符串
if (i_InputCheck==1) strl=strl+"H";
break;
}
m_InputEdit=strl;
UpdateData(FALSE);
}
void CCaculator03Dlg::On1Button()
{
// TODO: Add your control notification handler code here
int i_InputCheck=m_InputCheck.GetState();
switch (Radio)
{
case 'O':
val=val*8+1;
strl.Format("%o",val);//将输入的数据转换为字符串
if (i_InputCheck==1) strl=strl+"Q";
break;
case 'D':
val=val*10+1;
strl.Format("%d",val);//将输入的数据转换为字符串
if (i_InputCheck==1) strl=strl+"D";
break;
case 'H':
val=val*16+1;
strl.Format("%x",val);//将输入的数据转换为字符串
if (i_InputCheck==1) strl=strl+"H";
break;
}
m_InputEdit=strl;
UpdateData(FALSE);
}
void CCaculator03Dlg::On2Button()
{
// TODO: Add your control notification handler code here
int i_InputCheck=m_InputCheck.GetState();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -