comctldlg.cpp

来自「实现用户验证..画圆 显示当前系统时间 对VC很有帮助 1):修改字体背景色 2」· C++ 代码 · 共 98 行

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

#include "stdafx.h"
#include "RJ030413.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_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(CComctlDlg, CDialog)
	//{{AFX_MSG_MAP(CComctlDlg)
	ON_WM_HSCROLL()
	ON_WM_CTLCOLOR()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

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

BOOL CComctlDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	//..................................
	m_BrushBkClr.CreateSolidBrush(RGB(0,0,255));
		//........................................................................
	//m_Spin.SetBuddy(GetDlgItem(IDC_EDITLINEWT));
	m_Spin.SetRange(0,10);
	m_Spin.SetPos(1);
	m_Slider.SetRange(1,200);
	m_Slider.SetTicFreq(8);
	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 CComctlDlg::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);
}

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 hbr;.............................................
	return m_BrushBkClr;
}

⌨️ 快捷键说明

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