|
// 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);
|
}
|