📄 beziercetestdlg.cpp
字号:
// BezierCETestDlg.cpp : implementation file
//
#include "stdafx.h"
#include "BezierCETest.h"
#include "BezierCETestDlg.h"
#include "Bezier.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBezierCETestDlg dialog
CBezierCETestDlg::CBezierCETestDlg(CWnd* pParent /*=NULL*/)
: CDialog(CBezierCETestDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CBezierCETestDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CBezierCETestDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CBezierCETestDlg)
DDX_Control(pDX, IDC_SLIDER_QUALITY, m_sliderControl);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CBezierCETestDlg, CDialog)
//{{AFX_MSG_MAP(CBezierCETestDlg)
ON_WM_PAINT()
ON_NOTIFY(NM_CUSTOMDRAW, IDC_SLIDER_QUALITY, OnCustomdrawSliderQuality)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBezierCETestDlg message handlers
BOOL CBezierCETestDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// 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
CenterWindow(GetDesktopWindow()); // center to the hpc screen
m_sliderControl.SetRange(4, 32, TRUE);
m_nQuality = 18;
m_sliderControl.SetPos(18);
return TRUE; // return TRUE unless you set the focus to a control
}
void CBezierCETestDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
//
// Clear the area where we are drawing the Bezier-spline
//
CBrush aWhiteBrush(RGB(255, 255, 255));
dc.FillRect(CRect(10, 100, 230, 200), &aWhiteBrush);
//
// Setup some control points
//
CPoint aBezier[7] = { CPoint(10, 150), CPoint(30, 100), CPoint(60, 200), CPoint(90, 150), CPoint(150, 100), CPoint(210, 200), CPoint(230, 150) };
//
// Draw the two connected bezier-splines
//
DrawBeziers(&dc, &aBezier[0], 7, m_nQuality);
//
// A reference line
//
dc.MoveTo(0, 150);
dc.LineTo(240, 150);
// Do not call CDialog::OnPaint() for painting messages
}
void CBezierCETestDlg::OnCustomdrawSliderQuality(NMHDR* pNMHDR, LRESULT* pResult)
{
int nPos = m_sliderControl.GetPos();
if(nPos != m_nQuality)
{
m_nQuality = nPos;
RedrawWindow();
}
*pResult = 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -