chenluhua1980
2026-01-24 2a7efcf2a4bac5e7f9813975c87683ea09fb984e
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
// CMainContainer.cpp: 实现文件
//
 
#include "stdafx.h"
#include "BondEq.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);
    }
}