📄 dialogscale.cpp
字号:
// DialogScale.cpp : implementation file
//
#include "stdafx.h"
#include "CVenus.h"
#include "DialogScale.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDialogScale dialog
CDialogScale::CDialogScale(CWnd* pParent /*=NULL*/)
: CDialog(CDialogScale::IDD, pParent)
{
//{{AFX_DATA_INIT(CDialogScale)
m_fScale = 1.0f;
//}}AFX_DATA_INIT
m_pParent = pParent;
}
void CDialogScale::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDialogScale)
DDX_Control(pDX, IDC_SPIN_SCALE, m_spinScale);
DDX_Text(pDX, IDC_EDIT1, m_fScale);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDialogScale, CDialog)
//{{AFX_MSG_MAP(CDialogScale)
ON_WM_DESTROY()
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_SCALE, OnDeltaposSpinScale)
ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDialogScale message handlers
void CDialogScale::SetScale(float scale)
{
m_fScaleUser = scale;
}
float CDialogScale::GetScale()
{
return m_fScaleUser;
}
BOOL CDialogScale::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
if(m_fScaleUser < 1)
m_fScaleUser = 1;
if(m_fScaleUser > 10)
m_fScaleUser = 10;
m_fScale = m_fScaleUser;
UpdateData(false); // add by lzj
m_spinScale.SetBuddy (GetDlgItem( IDC_EDIT2));
m_spinScale.SetRange (10,100);
m_spinScale.SetPos ((int)m_fScale*10);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDialogScale::OnDestroy()
{
CDialog::OnDestroy();
UpdateData();
m_fScaleUser = m_fScale;
}
void CDialogScale::PostNcDestroy()
{
// TODO: Add your specialized code here and/or call the base class
((CMainFrame*)m_pParent)->DestroyScale();
delete this;
CDialog::PostNcDestroy();
}
void CDialogScale::OnDeltaposSpinScale(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
// TODO: Add your control notification handler code here
UpdateData();
m_fScale = (float)(m_spinScale.GetPos ())/10.0f;
m_fScaleUser = m_fScale;
UpdateData(FALSE);
((CMainFrame*)m_pParent)->RedrawPic ();
*pResult = 0;
}
void CDialogScale::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();
if(m_fScale < 1.0 || m_fScale > 10.0)
{
m_fScale = m_fScaleUser;
MessageBox(" 你只能输入1和10之间的实数!", "警告");
UpdateData(false);
}
else
{
m_fScaleUser = m_fScale;
m_spinScale.SetPos ((int)m_fScale*10);
UpdateData(FALSE);
((CMainFrame*)m_pParent)->RedrawPic ();
}
}
void CDialogScale::OnOK()
{
// TODO: Add extra validation here
DestroyWindow();
// CDialog::OnOK();
}
void CDialogScale::OnCancel()
{
// TODO: Add extra cleanup here
DestroyWindow();
// CDialog::OnCancel();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -