// CPageProOverview.cpp: 实现文件
|
//
|
|
#include "stdafx.h"
|
#include "Servo.h"
|
#include "CPageProdOverview.h"
|
#include "afxdialogex.h"
|
|
namespace
|
{
|
constexpr UINT_PTR kTimerRefreshId = 2001;
|
constexpr UINT kTimerRefreshIntervalMs = 5000;
|
}
|
|
IMPLEMENT_DYNAMIC(CPageProdOverview, CDialogEx)
|
|
CPageProdOverview::CPageProdOverview(CWnd* pParent /*=nullptr*/)
|
: CDialogEx(IDD_PROD_OVERVIEW, pParent)
|
, m_clrBackground(RGB(240, 240, 240))
|
{
|
}
|
|
CPageProdOverview::~CPageProdOverview()
|
{
|
}
|
|
void CPageProdOverview::DoDataExchange(CDataExchange* pDX)
|
{
|
CDialogEx::DoDataExchange(pDX);
|
}
|
|
void CPageProdOverview::SetBackgroundColor(COLORREF color)
|
{
|
m_clrBackground = color;
|
m_brushBackground.DeleteObject();
|
m_brushBackground.CreateSolidBrush(m_clrBackground);
|
if (::IsWindow(m_hWnd)) {
|
Invalidate();
|
}
|
}
|
|
BEGIN_MESSAGE_MAP(CPageProdOverview, CDialogEx)
|
ON_WM_CTLCOLOR()
|
ON_WM_DESTROY()
|
ON_WM_SIZE()
|
ON_WM_TIMER()
|
END_MESSAGE_MAP()
|
|
BOOL CPageProdOverview::OnInitDialog()
|
{
|
CDialogEx::OnInitDialog();
|
|
|
// 使用自定义标签
|
if (CWnd* pDay = GetDlgItem(IDC_PROD_DAY_OUTPUT)) {
|
m_labelDayOut.SubclassWindow(pDay->GetSafeHwnd());
|
m_labelDayOut.setFontSize(28);
|
m_labelDayOut.setNoteTextColor(RGB(128, 128, 128));
|
m_labelDayOut.setNote1(_T("白班产出"));
|
m_labelDayOut.setBackground(m_clrBackground);
|
m_labelDayOut.setForeground(RGB(18, 18, 18), TRUE);
|
}
|
if (CWnd* pNight = GetDlgItem(IDC_PROD_NIGHT_OUTPUT)) {
|
m_labelNightOut.SubclassWindow(pNight->GetSafeHwnd());
|
m_labelNightOut.setFontSize(28);
|
m_labelNightOut.setNoteTextColor(RGB(128, 128, 128));
|
m_labelNightOut.setNote1(_T("夜班产出"));
|
m_labelNightOut.setBackground(m_clrBackground);
|
m_labelNightOut.setForeground(RGB(18, 18, 18), TRUE);
|
}
|
if (CWnd* pDayTakt = GetDlgItem(IDC_PROD_DAY_TAKT)) {
|
m_labelDayTakt.SubclassWindow(pDayTakt->GetSafeHwnd());
|
m_labelDayTakt.setFontSize(28);
|
m_labelDayTakt.setNoteTextColor(RGB(128, 128, 128));
|
m_labelDayTakt.setNote1(_T("白班平均TT"));
|
m_labelDayTakt.setBackground(m_clrBackground);
|
m_labelDayTakt.setForeground(RGB(18, 18, 18), TRUE);
|
}
|
if (CWnd* pNightTakt = GetDlgItem(IDC_PROD_NIGHT_TAKT)) {
|
m_labelNightTakt.SubclassWindow(pNightTakt->GetSafeHwnd());
|
m_labelNightTakt.setFontSize(28);
|
m_labelNightTakt.setNoteTextColor(RGB(128, 128, 128));
|
m_labelNightTakt.setNote1(_T("夜班平均TT"));
|
m_labelNightTakt.setBackground(m_clrBackground);
|
m_labelNightTakt.setForeground(RGB(18, 18, 18), TRUE);
|
}
|
|
RefreshData();
|
m_timerId = SetTimer(kTimerRefreshId, kTimerRefreshIntervalMs, nullptr);
|
return TRUE;
|
}
|
|
HBRUSH CPageProdOverview::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
|
{
|
HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
|
|
if (nCtlColor == CTLCOLOR_DLG || nCtlColor == CTLCOLOR_STATIC) {
|
if (m_brushBackground.GetSafeHandle() == NULL) {
|
m_brushBackground.CreateSolidBrush(m_clrBackground);
|
}
|
pDC->SetBkMode(TRANSPARENT);
|
return (HBRUSH)m_brushBackground.GetSafeHandle();
|
}
|
|
return hbr;
|
}
|
|
void CPageProdOverview::OnDestroy()
|
{
|
if (m_timerId != 0) {
|
KillTimer(m_timerId);
|
m_timerId = 0;
|
}
|
CDialogEx::OnDestroy();
|
}
|
|
void CPageProdOverview::OnSize(UINT nType, int cx, int cy)
|
{
|
CDialogEx::OnSize(nType, cx, cy);
|
}
|
|
void CPageProdOverview::OnTimer(UINT_PTR nIDEvent)
|
{
|
if (nIDEvent == kTimerRefreshId) {
|
RefreshData();
|
}
|
CDialogEx::OnTimer(nIDEvent);
|
}
|
|
void CPageProdOverview::RefreshData()
|
{
|
CString text;
|
text.Format(_T("%d"), 123);
|
m_labelDayOut.setText(text);
|
text.Format(_T("%d"), 1235);
|
m_labelNightOut.setText(text);
|
|
m_labelDayTakt.setText(_T("1236"));
|
m_labelNightTakt.setText(_T("1238"));
|
}
|