📄 demodlg.cpp
字号:
// DemoDlg.cpp : implementation file
//
#include "stdafx.h"
#include "BackColor.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;
m_nBackColor = 0;
//}}AFX_DATA_INIT
// Set initial background color to cyan
m_brBack.CreateSolidBrush( RGB( 0, 255, 255 ) );
}
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);
DDX_Radio(pDX, IDC_CYAN, m_nBackColor);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDemoDlg, CDialog)
//{{AFX_MSG_MAP(CDemoDlg)
ON_WM_CTLCOLOR()
ON_BN_CLICKED(IDC_CYAN, OnBackgroundCyan)
ON_BN_CLICKED(IDC_YELLOW, OnBackgroundYellow)
ON_BN_CLICKED(IDC_FUSCHIA, OnBackgroundFuschia)
ON_BN_CLICKED(IDC_STANDARD, OnBackgroundStandard)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDemoDlg message handlers
HBRUSH CDemoDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
switch( nCtlColor )
{
case CTLCOLOR_BTN:
case CTLCOLOR_STATIC:
pDC->SetBkMode( TRANSPARENT );
// Fall through
case CTLCOLOR_DLG:
return static_cast<HBRUSH>( m_brBack.GetSafeHandle() );
}
return CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
}
void CDemoDlg::OnBackgroundCyan()
{
// 1 - Change the background color to cyan
m_brBack.DeleteObject();
m_brBack.CreateSolidBrush( RGB( 0, 255, 255 ) );
// 2 - Force the dialog to repaint
Invalidate( TRUE );
}
void CDemoDlg::OnBackgroundYellow()
{
// 1 - Change the background color to yellow
m_brBack.DeleteObject();
m_brBack.CreateSolidBrush( RGB( 255, 255, 0 ) );
// 2 - Force the dialog to repaint
Invalidate( TRUE );
}
void CDemoDlg::OnBackgroundFuschia()
{
// 1 - Change the background color to fuschia
m_brBack.DeleteObject();
m_brBack.CreateSolidBrush( RGB( 255, 0, 255 ) );
// 2 - Force the dialog to repaint
Invalidate( TRUE );
}
void CDemoDlg::OnBackgroundStandard()
{
// 1 - Change the background color to the standard background color
m_brBack.DeleteObject();
m_brBack.CreateSolidBrush( ::GetSysColor( COLOR_BTNFACE ) );
// 2 - Force the dialog to repaint
Invalidate( TRUE );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -