LAPTOP-SNT8I5JK\Boounion
2025-09-22 9e9e63ef44ff672989d7b78bf37afb2054267671
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
 
// GangBond2860EmulatorDlg.cpp : ÊµÏÖÎļþ
//
 
#include "stdafx.h"
#include "GangBond2860Emulator.h"
#include "GangBond2860EmulatorDlg.h"
#include "afxdialogex.h"
 
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
 
 
// ÓÃÓÚÓ¦ÓóÌÐò¡°¹ØÓÚ¡±²Ëµ¥ÏîµÄ CAboutDlg ¶Ô»°¿ò
 
class CAboutDlg : public CDialogEx
{
public:
    CAboutDlg();
 
// ¶Ô»°¿òÊý¾Ý
#ifdef AFX_DESIGN_TIME
    enum { IDD = IDD_ABOUTBOX };
#endif
 
    protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV Ö§³Ö
 
// ÊµÏÖ
protected:
    DECLARE_MESSAGE_MAP()
};
 
CAboutDlg::CAboutDlg() : CDialogEx(IDD_ABOUTBOX)
{
}
 
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialogEx::DoDataExchange(pDX);
}
 
BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
END_MESSAGE_MAP()
 
 
// CGangBond2860EmulatorDlg ¶Ô»°¿ò
 
 
 
CGangBond2860EmulatorDlg::CGangBond2860EmulatorDlg(CWnd* pParent /*=NULL*/)
    : CDialogEx(IDD_GANGBOND2860EMULATOR_DIALOG, pParent)
{
    m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
    m_pTab = nullptr;
    m_crBkgnd = RGB(255, 255, 255);
    m_hbrBkgnd = nullptr;
    m_pPageEquipment = nullptr;
    m_pPageUnitA = nullptr;
    m_pPageUnitB = nullptr;
}
 
void CGangBond2860EmulatorDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialogEx::DoDataExchange(pDX);
}
 
BEGIN_MESSAGE_MAP(CGangBond2860EmulatorDlg, CDialogEx)
    ON_WM_SYSCOMMAND()
    ON_WM_PAINT()
    ON_WM_QUERYDRAGICON()
    ON_WM_CTLCOLOR()
    ON_WM_DESTROY()
    ON_WM_SIZE()
    ON_NOTIFY(BYHMTAB_SEL_CHANGED, IDC_HMTAB1, &CGangBond2860EmulatorDlg::OnTabSelChanged)
END_MESSAGE_MAP()
 
 
// CGangBond2860EmulatorDlg ÏûÏ¢´¦Àí³ÌÐò
 
BOOL CGangBond2860EmulatorDlg::OnInitDialog()
{
    CDialogEx::OnInitDialog();
 
    // ½«¡°¹ØÓÚ...¡±²Ëµ¥ÏîÌí¼Óµ½ÏµÍ³²Ëµ¥ÖС£
 
    // IDM_ABOUTBOX ±ØÐëÔÚϵͳÃüÁΧÄÚ¡£
    ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
    ASSERT(IDM_ABOUTBOX < 0xF000);
 
    CMenu* pSysMenu = GetSystemMenu(FALSE);
    if (pSysMenu != NULL)
    {
        BOOL bNameValid;
        CString strAboutMenu;
        bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
        ASSERT(bNameValid);
        if (!strAboutMenu.IsEmpty())
        {
            pSysMenu->AppendMenu(MF_SEPARATOR);
            pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
        }
    }
 
    // ÉèÖô˶Ի°¿òµÄͼ±ê¡£  µ±Ó¦ÓóÌÐòÖ÷´°¿Ú²»ÊǶԻ°¿òʱ£¬¿ò¼Ü½«×Ô¶¯
    //  Ö´Ðд˲Ù×÷
    SetIcon(m_hIcon, TRUE);            // ÉèÖôóͼ±ê
    SetIcon(m_hIcon, FALSE);        // ÉèÖÃСͼ±ê
 
 
    // ×ÓÒ³Ãæ
    m_pPageEquipment = new CPageEquipment();
    m_pPageEquipment->Create(IDD_PAGE_EQUIPMENT, this);
    m_pPageUnitA = new CPageUnit();
    m_pPageUnitA->Create(IDD_PAGE_UNIT, this);
    m_pPageUnitA->setName("UNITA");    
    m_pPageUnitB = new CPageUnit();
    m_pPageUnitB->Create(IDD_PAGE_UNIT, this);
    m_pPageUnitB->setName("UNITB");
 
 
 
    // Tab
    m_pTab = CHmTab::Hook(GetDlgItem(IDC_HMTAB1)->m_hWnd);
    m_pTab->SetPaddingLeft(20);
    m_pTab->SetItemMarginLeft(18);
    m_pTab->SetBkgndColor(RGB(255, 255, 255));
    m_pTab->AddItem("»úÆ÷ÐÅÏ¢", FALSE);
    m_pTab->AddItem("UNITA", FALSE);
    m_pTab->AddItem("UNITB", FALSE);
    m_pTab->SetCurSel(0);
 
 
    ShowChildPage(0);
    // ShowWindow(SW_MAXIMIZE);
    Resize();
 
 
 
    return TRUE;  // ³ý·Ç½«½¹µãÉèÖõ½¿Ø¼þ£¬·ñÔò·µ»Ø TRUE
}
 
void CGangBond2860EmulatorDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
    if ((nID & 0xFFF0) == IDM_ABOUTBOX)
    {
        CAboutDlg dlgAbout;
        dlgAbout.DoModal();
    }
    else
    {
        CDialogEx::OnSysCommand(nID, lParam);
    }
}
 
// Èç¹ûÏò¶Ô»°¿òÌí¼Ó×îС»¯°´Å¥£¬ÔòÐèÒªÏÂÃæµÄ´úÂë
//  À´»æÖƸÃͼ±ê¡£  ¶ÔÓÚʹÓÃÎĵµ/ÊÓͼģÐ͵ĠMFC Ó¦ÓóÌÐò£¬
//  Õ⽫ÓÉ¿ò¼Ü×Ô¶¯Íê³É¡£
 
void CGangBond2860EmulatorDlg::OnPaint()
{
    if (IsIconic())
    {
        CPaintDC dc(this); // ÓÃÓÚ»æÖƵÄÉ豸ÉÏÏÂÎÄ
 
        SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
 
        // Ê¹Í¼±êÔÚ¹¤×÷Çø¾ØÐÎÖоÓÖÐ
        int cxIcon = GetSystemMetrics(SM_CXICON);
        int cyIcon = GetSystemMetrics(SM_CYICON);
        CRect rect;
        GetClientRect(&rect);
        int x = (rect.Width() - cxIcon + 1) / 2;
        int y = (rect.Height() - cyIcon + 1) / 2;
 
        // »æÖÆÍ¼±ê
        dc.DrawIcon(x, y, m_hIcon);
    }
    else
    {
        CDialogEx::OnPaint();
    }
}
 
//µ±Óû§Í϶¯×îС»¯´°¿Úʱϵͳµ÷Óô˺¯ÊýÈ¡µÃ¹â±ê
//ÏÔʾ¡£
HCURSOR CGangBond2860EmulatorDlg::OnQueryDragIcon()
{
    return static_cast<HCURSOR>(m_hIcon);
}
 
HBRUSH CGangBond2860EmulatorDlg::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 CGangBond2860EmulatorDlg::OnDestroy()
{
    CDialogEx::OnDestroy();
 
    if (m_pPageEquipment != nullptr) {
        m_pPageEquipment->DestroyWindow();
        delete m_pPageEquipment;
        m_pPageEquipment = nullptr;
    }
 
    if (m_pPageUnitA != nullptr) {
        m_pPageUnitA->DestroyWindow();
        delete m_pPageUnitA;
        m_pPageUnitA = nullptr;
    }
 
    if (m_pPageUnitB != nullptr) {
        m_pPageUnitB->DestroyWindow();
        delete m_pPageUnitB;
        m_pPageUnitB = nullptr;
    }
 
    if (m_hbrBkgnd != nullptr) {
        ::DeleteObject(m_hbrBkgnd);
    }
}
 
void CGangBond2860EmulatorDlg::OnSize(UINT nType, int cx, int cy)
{
    CDialogEx::OnSize(nType, cx, cy);
    if (GetDlgItem(IDC_HMTAB1) == nullptr) return;
    Resize();
}
 
void CGangBond2860EmulatorDlg::ShowChildPage(int index)
{
    ASSERT(0 <= index && index < 3);
    static CWnd* pPages[] = { m_pPageEquipment, m_pPageUnitA, m_pPageUnitB };
    for (int i = 0; i < 3; i++) {
        pPages[i]->ShowWindow(i == index ? SW_SHOW : SW_HIDE);
    }
}
 
void CGangBond2860EmulatorDlg::OnTabSelChanged(NMHDR* nmhdr, LRESULT* result)
{
    BYHMTAB_NMHDR* pNmhdrex = (BYHMTAB_NMHDR*)nmhdr;
    ShowChildPage((int)pNmhdrex->dwData);
 
    *result = 0;
}
 
void CGangBond2860EmulatorDlg::Resize()
{
    CRect rcClient, rcItem;
    GetClientRect(&rcClient);
 
    int x = 8;
    int y = 12;
    GetDlgItem(IDC_HMTAB1)->GetWindowRect(&rcItem);
    GetDlgItem(IDC_HMTAB1)->MoveWindow(x, y, rcClient.Width() - x * 2, rcItem.Height());
    y += rcItem.Height();
    y += 1;
 
    m_pPageEquipment->MoveWindow(x, y, rcClient.Width() - x * 2, rcClient.Height() - y);
    m_pPageUnitA->MoveWindow(x, y, rcClient.Width() - x * 2, rcClient.Height() - y);
    m_pPageUnitB->MoveWindow(x, y, rcClient.Width() - x * 2, rcClient.Height() - y);
}