comctdlg.cpp
来自「MFC的画圆工具」· C++ 代码 · 共 80 行
CPP
80 行
// ComctDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ExampComctl.h"
#include "ComctDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CComctDlg dialog
CComctDlg::CComctDlg(CWnd* pParent /*=NULL*/)
: CDialog(CComctDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CComctDlg)
m_nLineWt = 0;
m_nRadius = 0;
//}}AFX_DATA_INIT
}
void CComctDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CComctDlg)
DDX_Control(pDX, IDC_SLIDERRADIUS, m_Slider);
DDX_Control(pDX, IDC_SPINLINEWT, m_Spin);
DDX_Text(pDX, IDC_EDITLINEWT, m_nLineWt);
DDV_MinMaxUInt(pDX, m_nLineWt, 0, 10);
DDX_Slider(pDX, IDC_SLIDERRADIUS, m_nRadius);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CComctDlg, CDialog)
//{{AFX_MSG_MAP(CComctDlg)
ON_WM_HSCROLL()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CComctDlg message handlers
BOOL CComctDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_Spin.SetBuddy(GetDlgItem(IDC_EDITLINEWT));
m_Spin.SetRange(0,10);
m_Spin.SetPos(1);
m_Slider.SetRange(1,200);
m_Slider.SetTicFreq(10);
m_Slider.SetPos(50);
m_Slider.SetSelection(50,150);
SetDlgItemText(IDC_STATICRADIUS,"半径:50");
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CComctDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
if(pScrollBar->GetDlgCtrlID()==IDC_SLIDERRADIUS)
m_nRadius=m_Slider.GetPos();
CString strRadius;
strRadius.Format("半径:%d", m_nRadius);
SetDlgItemText(IDC_STATICRADIUS, strRadius);
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?