📄 demodlg.cpp
字号:
// DemoDlg.cpp : implementation file
//
#include "stdafx.h"
#include "CustomControlDlg.h"
#include "DemoDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDemoDlg dialog
CDemoDlg::CDemoDlg(CWnd* pParent /*=NULL*/)
: CDialog(CDemoDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CDemoDlg)
m_nX = 0;
m_nY = 0;
m_nShape = -1;
//}}AFX_DATA_INIT
}
void CDemoDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDemoDlg)
DDX_Control(pDX, IDC_SHAPE, m_cmbShape);
DDX_Control(pDX, IDC_Y, m_edtY);
DDX_Control(pDX, IDC_X, m_edtX);
DDX_Text(pDX, IDC_X, m_nX);
DDX_Text(pDX, IDC_Y, m_nY);
DDX_CBIndex(pDX, IDC_SHAPE, m_nShape);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDemoDlg, CDialog)
//{{AFX_MSG_MAP(CDemoDlg)
ON_WM_CTLCOLOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDemoDlg message handlers
HBRUSH CDemoDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// IDC_STATIC_X and IDC_STATIC_Y controls
// draw their text in BLUE
if( pWnd->GetDlgCtrlID() == IDC_STATIC_X
|| pWnd->GetDlgCtrlID() == IDC_STATIC_Y )
{
pDC->SetTextColor( RGB( 0, 0, 255 ) ); // BLUE
}
// IDC_X and IDC_Y controls draw their text in RED
if( pWnd->GetDlgCtrlID() == IDC_X
|| pWnd->GetDlgCtrlID() == IDC_Y )
{
pDC->SetTextColor( RGB( 255, 0, 0 ) ); // RED
}
return hbr;
}
BOOL CDemoDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CClientDC dc( this ); // need a DC for GetDeviceCaps() below
LOGFONT lf; // logical font structure
::ZeroMemory( &lf, sizeof( lf ) );
// 12 point Times bold
lf.lfHeight = - MulDiv( 12, dc.GetDeviceCaps( LOGPIXELSX ), 72 );
lf.lfWidth = 0;
lf.lfEscapement = 0;
lf.lfOrientation = 0;
lf.lfWeight = FW_BOLD;
lf.lfItalic = FALSE;
lf.lfUnderline = FALSE;
lf.lfStrikeOut = FALSE;
lf.lfCharSet = DEFAULT_CHARSET;
lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
lf.lfQuality = DEFAULT_QUALITY;
lf.lfPitchAndFamily = VARIABLE_PITCH | FF_ROMAN;
// Create font
m_font1.CreateFontIndirect( &lf );
// Set control font
GetDlgItem( IDC_STATIC_X )->SetFont( &m_font1 );
GetDlgItem( IDC_STATIC_Y )->SetFont( &m_font1 );
// 12 point Arial bold italic
lf.lfItalic = TRUE;
lf.lfPitchAndFamily = VARIABLE_PITCH | FF_SWISS;
// Create font
m_font2.CreateFontIndirect( &lf );
// Set control font
GetDlgItem( IDC_X )->SetFont( &m_font2 );
GetDlgItem( IDC_Y )->SetFont( &m_font2 );
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -