// CPanelProject.cpp: 实现文件
|
//
|
|
#include "stdafx.h"
|
#include "BondEq.h"
|
#include "CPanelProject.h"
|
#include "afxdialogex.h"
|
|
|
// CPanelEquipment 对话框
|
|
IMPLEMENT_DYNAMIC(CPanelProject, CDialogEx)
|
|
CPanelProject::CPanelProject(CWnd* pParent /*=nullptr*/)
|
: CDialogEx(IDD_PANEL_PROJECT, pParent)
|
{
|
m_crBkgnd = RGB(252, 252, 255);
|
m_hbrBkgnd = nullptr;
|
m_nPanelWidth = int((double)GetSystemMetrics(SM_CXSCREEN) * 0.25);
|
m_pAccordionWnd = nullptr;
|
//m_pPageRemoteEqs = nullptr;
|
m_pPageMain = nullptr;
|
m_pPageComponents = nullptr;
|
}
|
|
CPanelProject::~CPanelProject()
|
{
|
}
|
|
void CPanelProject::DoDataExchange(CDataExchange* pDX)
|
{
|
CDialogEx::DoDataExchange(pDX);
|
}
|
|
|
BEGIN_MESSAGE_MAP(CPanelProject, CDialogEx)
|
ON_WM_SIZE()
|
ON_WM_CTLCOLOR()
|
ON_WM_DESTROY()
|
ON_NOTIFY(BYVERTICALLINE_MOVEX, IDC_LINE1, &CPanelProject::OnVLineMoveX)
|
END_MESSAGE_MAP()
|
|
|
// CPanelEquipment 消息处理程序
|
|
|
BOOL CPanelProject::OnInitDialog()
|
{
|
CDialogEx::OnInitDialog();
|
|
|
// 读取面板宽
|
CString strIniFile;
|
strIniFile.Format(_T("%s\\configuration.ini"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
|
m_nPanelWidth = GetPrivateProfileInt(_T("App"), _T("PanelEquipmentWidth"),
|
int((double)GetSystemMetrics(SM_CXSCREEN) * 0.25), (LPTSTR)(LPCTSTR)strIniFile);
|
|
CVerticalLine* pLine = CVerticalLine::Hook(GetDlgItem(IDC_LINE1)->GetSafeHwnd());
|
pLine->EnableResize();
|
|
|
// 分组展开收起控件
|
CString strExpandIcon, strCloseIcon;
|
strExpandIcon.Format(_T("%s\\res\\arrow_down.ico"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
|
strCloseIcon.Format(_T("%s\\res\\arrow_right.ico"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
|
|
m_pAccordionWnd = CAccordionWnd::FromHandle(GetDlgItem(IDC_ACCORDION_WND1)->m_hWnd);
|
m_pAccordionWnd->SetFrameColor(RGB(220, 220, 220), TRUE);
|
m_pAccordionWnd->Setpadding(PADDING_LEFT, 2);
|
m_pAccordionWnd->Setpadding(PADDING_TOP, 2);
|
m_pAccordionWnd->Setpadding(PADDING_RIGHT, 2);
|
m_pAccordionWnd->Setpadding(PADDING_BOTTOM, 2);
|
m_pAccordionWnd->LoadExpandIcon(strExpandIcon, strCloseIcon);
|
|
//m_pPageRemoteEqs = new CProjectPageRemoteEqs();
|
//m_pPageRemoteEqs->Create(IDD_PROJECT_PAGE_REMOTEEQS, GetDlgItem(IDC_ACCORDION_WND1));
|
//m_pPageRemoteEqs->ShowWindow(SW_SHOW);
|
//m_pAccordionWnd->AddItem("远程设备", m_pPageRemoteEqs, 0, TRUE, TRUE);
|
|
m_pPageMain = new CProjectPageMain();
|
m_pPageMain->Create(IDD_PROJECT_PAGE_MAIN, GetDlgItem(IDC_ACCORDION_WND1));
|
m_pPageMain->ShowWindow(SW_SHOW);
|
m_pAccordionWnd->AddItem("主页面", m_pPageMain, 0, TRUE, TRUE);
|
|
m_pPageComponents = new CProjectPageComponents();
|
m_pPageComponents->Create(IDD_PROJECT_PAGE_COMPONENTS, GetDlgItem(IDC_ACCORDION_WND1));
|
m_pPageComponents->ShowWindow(SW_SHOW);
|
m_pAccordionWnd->AddItem("组件列表", m_pPageComponents, -1, TRUE, TRUE);
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
// 异常: OCX 属性页应返回 FALSE
|
}
|
|
void CPanelProject::OnSize(UINT nType, int cx, int cy)
|
{
|
CDialogEx::OnSize(nType, cx, cy);
|
if(GetDlgItem(IDC_LINE1) == nullptr) return;
|
Resize();
|
}
|
|
HBRUSH CPanelProject::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
|
{
|
HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
|
|
if (nCtlColor == CTLCOLOR_STATIC) {
|
pDC->SetBkColor(m_crBkgnd);
|
}
|
|
if (m_hbrBkgnd == nullptr) {
|
m_hbrBkgnd = CreateSolidBrush(m_crBkgnd);
|
}
|
|
return m_hbrBkgnd;
|
}
|
|
void CPanelProject::OnDestroy()
|
{
|
CDialogEx::OnDestroy();
|
|
if (m_hbrBkgnd != nullptr) {
|
::DeleteObject(m_hbrBkgnd);
|
}
|
|
if (m_pPageComponents != nullptr) {
|
m_pPageComponents->DestroyWindow();
|
delete m_pPageComponents;
|
m_pPageComponents = nullptr;
|
}
|
|
//if (m_pPageRemoteEqs != nullptr) {
|
// m_pPageRemoteEqs->DestroyWindow();
|
// delete m_pPageRemoteEqs;
|
// m_pPageRemoteEqs = nullptr;
|
//}
|
|
if (m_pPageMain != nullptr) {
|
m_pPageMain->DestroyWindow();
|
delete m_pPageMain;
|
m_pPageMain = nullptr;
|
}
|
}
|
|
void CPanelProject::Resize()
|
{
|
CRect rcClient, rcItem;
|
GetClientRect(&rcClient);
|
|
CWnd* pLine = GetDlgItem(IDC_LINE1);
|
pLine->MoveWindow(rcClient.right - 2, 0, 2, rcClient.Height());
|
|
GetDlgItem(IDC_ACCORDION_WND1)->MoveWindow(0, 0, rcClient.Width() - 2, rcClient.Height());
|
}
|
|
#define LEFT_PANEL_MIN_WIDTH 80
|
#define LEFT_PANEL_MAX_WIDTH 880
|
void CPanelProject::OnVLineMoveX(NMHDR* nmhdr, LRESULT* result)
|
{
|
BYVERTICALLINE_NMHDR* pNmhdrex = (BYVERTICALLINE_NMHDR*)nmhdr;
|
int x = pNmhdrex->dwData;
|
m_nPanelWidth += x;
|
m_nPanelWidth = max(m_nPanelWidth, LEFT_PANEL_MIN_WIDTH);
|
m_nPanelWidth = min(m_nPanelWidth, LEFT_PANEL_MAX_WIDTH);
|
GetParent()->SendMessage(WM_SIZE, 0, 0);
|
|
CString strIniFile, strValue;
|
strIniFile.Format(_T("%s\\configuration.ini"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
|
strValue.Format(_T("%d"), m_nPanelWidth);
|
WritePrivateProfileString(_T("App"), _T("PanelEquipmentWidth"),
|
(LPTSTR)(LPCTSTR)strValue, (LPTSTR)(LPCTSTR)strIniFile);
|
|
*result = 0;
|
}
|
|
int CPanelProject::GetPanelWidth()
|
{
|
return m_nPanelWidth;
|
}
|