// CPjPage1.cpp: 实现文件
|
//
|
|
#include "stdafx.h"
|
#include "Servo.h"
|
#include "CCjPage1.h"
|
#include "afxdialogex.h"
|
|
|
// CPjPage1 对话框
|
|
IMPLEMENT_DYNAMIC(CCjPage1, CDialogEx)
|
|
CCjPage1::CCjPage1(CWnd* pParent /*=nullptr*/)
|
: CDialogEx(IDD_CJ_PAGE1, pParent)
|
{
|
m_crBkgnd = RGB(255, 255, 255);
|
m_crBkgndCached = CLR_INVALID;
|
}
|
|
CCjPage1::~CCjPage1()
|
{
|
}
|
|
void CCjPage1::DoDataExchange(CDataExchange* pDX)
|
{
|
CDialogEx::DoDataExchange(pDX);
|
}
|
|
|
BEGIN_MESSAGE_MAP(CCjPage1, CDialogEx)
|
ON_WM_CTLCOLOR()
|
ON_WM_DESTROY()
|
ON_WM_SIZE()
|
END_MESSAGE_MAP()
|
|
|
// CPjPage1 消息处理程序
|
|
|
BOOL CCjPage1::OnInitDialog()
|
{
|
CDialogEx::OnInitDialog();
|
Resize();
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
// 异常: OCX 属性页应返回 FALSE
|
}
|
|
|
HBRUSH CCjPage1::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
|
{
|
HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
|
|
// 想给哪些控件改底色就把它们的类型写进来:
|
const bool needCustomBg =
|
(nCtlColor == CTLCOLOR_STATIC) ||
|
(nCtlColor == CTLCOLOR_DLG) || // 对话框底色
|
(nCtlColor == CTLCOLOR_BTN); // 按钮(可选)
|
|
if (needCustomBg)
|
{
|
// 若第一次创建,或颜色改变则重建
|
if (m_brBkgnd.GetSafeHandle() == nullptr || m_crBkgndCached != m_crBkgnd)
|
{
|
if (m_brBkgnd.GetSafeHandle())
|
m_brBkgnd.DeleteObject();
|
|
m_brBkgnd.CreateSolidBrush(m_crBkgnd);
|
m_crBkgndCached = m_crBkgnd;
|
}
|
|
// 文本前景/背景设置(仅影响文本绘制)
|
pDC->SetBkColor(m_crBkgnd);
|
pDC->SetTextColor(RGB(0, 0, 0));
|
// 如需让静态文本透明叠在底色上,可用:
|
// pDC->SetBkMode(TRANSPARENT);
|
|
return (HBRUSH)m_brBkgnd; // 安全的隐式转换
|
}
|
|
// 其他控件类型沿用基类默认的刷子
|
return hbr;
|
}
|
|
void CCjPage1::OnDestroy()
|
{
|
CDialogEx::OnDestroy();
|
|
// TODO: 在此处添加消息处理程序代码
|
}
|
|
void CCjPage1::OnSize(UINT nType, int cx, int cy)
|
{
|
CDialogEx::OnSize(nType, cx, cy);
|
if (GetDlgItem(IDC_LABEL_NO_SEL) == nullptr) return;
|
Resize();
|
}
|
|
void CCjPage1::Resize()
|
{
|
CWnd* pItem;
|
CRect rcClient, rcItem;
|
GetClientRect(&rcClient);
|
pItem = GetDlgItem(IDC_LABEL_NO_SEL);
|
pItem->GetWindowRect(&rcItem);
|
pItem->MoveWindow((rcClient.Width() - rcItem.Width()) / 2,
|
(rcClient.Height() - rcItem.Height()) / 2,
|
rcItem.Width(), rcItem.Height());
|
}
|