chenluhua1980
2025-12-17 e3729db9e5b77d253666d9c7287bf2ea84c05132
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// CPanelProduction.cpp
//
 
#include "stdafx.h"
#include "Servo.h"
#include "CPanelProduction.h"
#include "afxdialogex.h"
#include "Common.h"
#include "VerticalLine.h"
#include <cstring>
#include <vector>
 
 
// 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()
{
    ShowWindow(SW_HIDE);
    GetParent()->SendMessage(ID_MSG_PANEL_RESIZE, m_nPanelWidth, 0);
}