📄 inputdialog.cpp
字号:
// InputDialog.cpp : implementation file
//
#include "stdafx.h"
#include "BmpTest.h"
#include "InputDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CInputDialog dialog
CInputDialog::CInputDialog(CWnd* pParent /*=NULL*/)
: CDialog(CInputDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CInputDialog)
m_Xt = 0;
m_Xb = 0;
m_Yb = 0;
m_Yt = 0;
//}}AFX_DATA_INIT
}
void CInputDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CInputDialog)
DDX_Control(pDX, IDC_PREVIEW, m_Preview);
DDX_Text(pDX, IDC_XT, m_Xt);
DDV_MinMaxUInt(pDX, m_Xt, 0, 10000);
DDX_Text(pDX, IDC_XB, m_Xb);
DDV_MinMaxUInt(pDX, m_Xb, 0, 10000);
DDX_Text(pDX, IDC_YB, m_Yb);
DDV_MinMaxUInt(pDX, m_Yb, 0, 10000);
DDX_Text(pDX, IDC_YT, m_Yt);
DDV_MinMaxUInt(pDX, m_Yt, 0, 10000);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CInputDialog, CDialog)
//{{AFX_MSG_MAP(CInputDialog)
ON_WM_PAINT()
ON_EN_CHANGE(IDC_XB, OnChange)
ON_EN_CHANGE(IDC_XT, OnChange)
ON_EN_CHANGE(IDC_YB, OnChange)
ON_EN_CHANGE(IDC_YT, OnChange)
ON_COMMAND(ID_ZFT_BALANCE, OnZftBalance)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CInputDialog message handlers
//●:
BOOL CInputDialog::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_Preview.GetWindowRect(rcDest);
m_Dib.LoadBmp(m_FileName);
rcSrc.left=0;
rcSrc.top=0;
rcSrc.right=m_Dib.Width;
rcSrc.bottom=m_Dib.Height;
m_Xt=rcDest.left+rcDest.Width()/3;
m_Yt=rcDest.top+rcDest.Height()/3;
m_Xb=rcDest.right-rcDest.Width()/3;
m_Yb=rcDest.bottom-rcDest.Height()/3;
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CInputDialog::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
m_Dib.Draw(dc.GetSafeHdc(),rcDest,rcSrc);
CBrush br, * obr;
br.CreateStockObject(NULL_BRUSH);
obr=dc.SelectObject(&br);
dc.Rectangle(m_Xt,m_Yt,m_Xb,m_Yb);
dc.SelectObject(obr);
br.DeleteObject();
// Do not call CDialog::OnPaint() for painting messages
}
void CInputDialog::OnChange()
{
// 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();
Sort(m_Xt,m_Xb);
Sort(m_Yt,m_Yb);
if(m_Xt<rcDest.left)
{
m_Xt=rcDest.left;
}
if(m_Yt<rcDest.top)
{
m_Yt=rcDest.top;
}
if(m_Xb>rcDest.right)
{
m_Xb=rcDest.right;
}
if(m_Yb>rcDest.bottom)
{
m_Yb=rcDest.bottom;
}
InvalidateRect(rcDest,TRUE);
UpdateWindow();
}
void CInputDialog::Sort(UINT &x0, UINT &x1)
{
UINT t;
if(x0>x1)
{
t=x1;
x1=x0;
x0=t;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -