// CPanelProduction.cpp
|
//
|
|
#include "stdafx.h"
|
#include "Servo.h"
|
#include "CPanelProduction.h"
|
#include "afxdialogex.h"
|
#include "Common.h"
|
#include "VerticalLine.h"
|
|
|
// CPanelProduction dialog
|
|
IMPLEMENT_DYNAMIC(CPanelProduction, CDialogEx)
|
|
CPanelProduction::CPanelProduction(CWnd* pParent /*=nullptr*/)
|
: CDialogEx(IDD_PANEL_PRODUCTION, pParent)
|
{
|
m_crBkgnd = PANEL_PRODUCTION_BACKGROUND_COLOR;
|
m_hbrBkgnd = nullptr;
|
m_nPanelWidth = 288;
|
m_hPlaceholder = nullptr;
|
}
|
|
CPanelProduction::~CPanelProduction()
|
{
|
}
|
|
void CPanelProduction::DoDataExchange(CDataExchange* pDX)
|
{
|
CDialogEx::DoDataExchange(pDX);
|
}
|
|
|
BEGIN_MESSAGE_MAP(CPanelProduction, CDialogEx)
|
ON_WM_CTLCOLOR()
|
ON_WM_DESTROY()
|
ON_WM_SIZE()
|
ON_NOTIFY(BYVERTICALLINE_MOVEX, IDC_LINE1, &CPanelProduction::OnVLineMoveX)
|
ON_BN_CLICKED(IDC_BUTTON_CLOSE, &CPanelProduction::OnBnClickedButtonClose)
|
END_MESSAGE_MAP()
|
|
int CPanelProduction::getPanelWidth()
|
{
|
return m_nPanelWidth;
|
}
|
|
void CPanelProduction::setPanelWidth(int width)
|
{
|
m_nPanelWidth = width;
|
}
|
|
BOOL CPanelProduction::OnInitDialog()
|
{
|
CDialogEx::OnInitDialog();
|
|
CVerticalLine* pLine1 = CVerticalLine::Hook(GetDlgItem(IDC_LINE1)->GetSafeHwnd());
|
pLine1->SetBkgndColor(RGB(225, 225, 225));
|
pLine1->SetLineColor(RGB(198, 198, 198));
|
pLine1->EnableResize();
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
// Exception: OCX property pages should return FALSE
|
}
|
|
HBRUSH CPanelProduction::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
|
{
|
HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
|
|
if (nCtlColor == CTLCOLOR_STATIC) {
|
pDC->SetBkColor(m_crBkgnd);
|
pDC->SetTextColor(RGB(0, 0, 0));
|
}
|
|
if (m_hbrBkgnd == nullptr) {
|
m_hbrBkgnd = CreateSolidBrush(m_crBkgnd);
|
}
|
|
return m_hbrBkgnd;
|
}
|
|
void CPanelProduction::OnDestroy()
|
{
|
CDialogEx::OnDestroy();
|
|
if (m_hbrBkgnd != nullptr) {
|
::DeleteObject(m_hbrBkgnd);
|
}
|
}
|
|
void CPanelProduction::OnSize(UINT nType, int cx, int cy)
|
{
|
CDialogEx::OnSize(nType, cx, cy);
|
if (GetDlgItem(IDC_LINE1) == nullptr) return;
|
|
CWnd* pItem;
|
CRect rcClient, rcItem;
|
|
GetClientRect(&rcClient);
|
pItem = GetDlgItem(IDC_LINE1);
|
pItem->MoveWindow(rcClient.right - 3, 0, 3, rcClient.Height());
|
}
|
|
#define PRODUCTION_PANEL_MIN_WIDTH 88
|
#define PRODUCTION_PANEL_MAX_WIDTH 588
|
void CPanelProduction::OnVLineMoveX(NMHDR* nmhdr, LRESULT* result)
|
{
|
BYVERTICALLINE_NMHDR* pNmhdrex = (BYVERTICALLINE_NMHDR*)nmhdr;
|
int x = pNmhdrex->dwData;
|
m_nPanelWidth += x;
|
m_nPanelWidth = max(m_nPanelWidth, PRODUCTION_PANEL_MIN_WIDTH);
|
m_nPanelWidth = min(m_nPanelWidth, PRODUCTION_PANEL_MAX_WIDTH);
|
GetParent()->SendMessage(ID_MSG_PANEL_RESIZE, m_nPanelWidth, 0);
|
OnSize(0, 0, 0);
|
|
*result = 0;
|
}
|
|
void CPanelProduction::OnBnClickedButtonClose()
|
{
|
CWnd* pParent = GetParent();
|
if (pParent != nullptr) {
|
pParent->PostMessage(WM_COMMAND, ID_MENU_WND_TEST_PANEL, 0);
|
}
|
}
|