// CMainContainer.cpp: 实现文件
|
//
|
|
#include "stdafx.h"
|
#include "BoounionPLC.h"
|
#include "Common.h"
|
#include "CMainContainer.h"
|
#include "afxdialogex.h"
|
|
|
// CMainContainer 对话框
|
|
IMPLEMENT_DYNAMIC(CMainContainer, CDialogEx)
|
|
CMainContainer::CMainContainer(CWnd* pParent /*=nullptr*/)
|
: CDialogEx(IDD_MAIN_CONTAINER, pParent)
|
{
|
m_crBkgnd = MAIN_CONTAINER_BACKGROUND;
|
m_hbrBkgnd = nullptr;
|
}
|
|
CMainContainer::~CMainContainer()
|
{
|
}
|
|
void CMainContainer::DoDataExchange(CDataExchange* pDX)
|
{
|
CDialogEx::DoDataExchange(pDX);
|
}
|
|
|
BEGIN_MESSAGE_MAP(CMainContainer, CDialogEx)
|
ON_WM_CTLCOLOR()
|
ON_WM_DESTROY()
|
ON_WM_SIZE()
|
END_MESSAGE_MAP()
|
|
|
// CMainContainer 消息处理程序
|
|
|
BOOL CMainContainer::OnInitDialog()
|
{
|
CDialogEx::OnInitDialog();
|
|
// TODO: 在此添加额外的初始化
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
// 异常: OCX 属性页应返回 FALSE
|
}
|
|
|
HBRUSH CMainContainer::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 CMainContainer::OnDestroy()
|
{
|
CDialogEx::OnDestroy();
|
|
if (m_hbrBkgnd != nullptr) {
|
::DeleteObject(m_hbrBkgnd);
|
}
|
}
|
|
|
void CMainContainer::OnSize(UINT nType, int cx, int cy)
|
{
|
CDialogEx::OnSize(nType, cx, cy);
|
Resize();
|
}
|
|
void CMainContainer::Resize()
|
{
|
CRect rcClient;
|
GetClientRect(&rcClient);
|
|
// 先取得子窗口数量
|
int count = 0;
|
CWnd* pClild = FindWindowEx(m_hWnd, NULL, NULL, NULL);
|
while (pClild != nullptr) {
|
count++;
|
pClild = FindWindowEx(m_hWnd, pClild->m_hWnd, NULL, NULL);
|
}
|
|
pClild = FindWindowEx(m_hWnd, NULL, NULL, NULL);
|
while (pClild != nullptr) {
|
pClild->MoveWindow(&rcClient);
|
if (::GetProp(pClild->GetSafeHwnd(), "Home") == (HANDLE)1) {
|
pClild->ShowWindow(count == 1 ? SW_SHOW : SW_HIDE);
|
}
|
else {
|
pClild->ShowWindow(SW_SHOW);
|
}
|
|
pClild = FindWindowEx(m_hWnd, pClild->m_hWnd, NULL, NULL);
|
}
|
}
|