comctldlg.cpp

来自「VC++一些代码,自己制作,可以实现密码登录,有画圆等功能.」· C++ 代码 · 共 89 行

CPP
89
字号
// ComctlDlg.cpp : implementation file
//

#include "stdafx.h"
#include "RJ030619.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_SLIDER_RADIUS, m_Slider);
	DDX_Text(pDX, IDC_EDITLINEWT, m_nLineWt);
	DDX_Slider(pDX, IDC_SLIDER_RADIUS, m_nRadius);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CComctlDlg, CDialog)
	//{{AFX_MSG_MAP(CComctlDlg)
	ON_WM_HSCROLL()
	ON_WM_CTLCOLOR()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CComctlDlg message handlers

void CComctlDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
	// TODO: Add your message handler code here and/or call default
	if(pScrollBar->GetDlgCtrlID()==IDC_SLIDER_RADIUS)
		m_nRadius=m_Slider.GetPos();
	CString strRadius;
	strRadius.Format("半径:%d",m_nRadius);
	SetDlgItemText(IDC_STATIC_RADIUS,strRadius);
	CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}

BOOL CComctlDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	
	m_BrushBkClr.CreateSolidBrush(RGB(0,255,200));
	////////////////////////
	m_Spin.SetRange(0,10);//设置旋转按钮的最小值和最大值
	m_Spin.SetPos(2);//设置旋转按钮的当前位置
	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_STATIC_RADIUS,"半径:50");
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

HBRUSH CComctlDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
	
	// TODO: Change any attributes of the DC here
	
	// TODO: Return a different brush if the default is not desired
    return m_BrushBkClr;//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?