📄 comctldlg.cpp
字号:
// ComctlDlg.cpp : implementation file
//
#include "stdafx.h"
//#include "ExmpComctl.h"
#include "ExmpTabCtl.h" // 修改为应用程序类头文件
#include "ComctlDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CComctlDlg dialog
CComctlDlg::CComctlDlg(CWnd* pParent /*=NULL*/)
: CDialog(CComctlDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CComctlDlg)
m_nLineWt = 0;
m_nRadius = 0;
//}}AFX_DATA_INIT
}
void CComctlDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CComctlDlg)
DDX_Control(pDX, IDC_SPINLINEWT, m_Spin);
DDX_Control(pDX, IDC_SLIDERRADIUS, m_Slider);
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(CComctlDlg, CDialog)
//{{AFX_MSG_MAP(CComctlDlg)
ON_WM_HSCROLL()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CComctlDlg message handlers
BOOL CComctlDlg::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); // 设置滑块的最小、最大值范围1~200
m_Slider.SetTicFreq(10); // 设置滑块刻度标尺,每10个单位一个标记
m_Slider.SetPos(50); // 设置滑块的当前位置
m_Slider.SetSelection(50,150); // 设置滑块正常值的范围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 CComctlDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
if(pScrollBar->GetDlgCtrlID()==IDC_SLIDERRADIUS) // 判断滚动消息WM_HSCROLL是否由滑块发出
m_nRadius=m_Slider.GetPos(); // 也可通过调用函数UpdateData()获取滑块当前位置值
CString strRadius;
strRadius.Format("半径:%d",m_nRadius);
SetDlgItemText(IDC_STATICRADIUS,strRadius); // 设置静态文本控件的显示文本
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -