LAPTOP-SNT8I5JK\Boounion
2024-12-02 df0863b2c29fa227d186e6b8aeb4a856dcae12f3
1.增加PLC组件页
已添加4个文件
已修改6个文件
724 ■■■■■ 文件已修改
SourceCode/Bond/BondEq/BondEq.rc 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/BondEq/BondEq.vcxproj 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/BondEq/BondEqDlg.cpp 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/BondEq/BondEqDlg.h 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/BondEq/CComponentDlg.cpp 415 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/BondEq/CComponentDlg.h 73 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/BondEq/CComponentPLCDlg.cpp 123 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/BondEq/CComponentPLCDlg.h 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/BondEq/Common.h 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/BondEq/Resource.h 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/BondEq/BondEq.rc
Binary files differ
SourceCode/Bond/BondEq/BondEq.vcxproj
@@ -191,6 +191,8 @@
    <Text Include="ReadMe.txt" />
  </ItemGroup>
  <ItemGroup>
    <ClInclude Include="CComponentDlg.h" />
    <ClInclude Include="CComponentPLCDlg.h" />
    <ClInclude Include="CPLC.h" />
    <ClInclude Include="AccordionWnd.h" />
    <ClInclude Include="Alarm.h" />
@@ -261,6 +263,8 @@
    <ClInclude Include="View\UserManagerDlg.h" />
  </ItemGroup>
  <ItemGroup>
    <ClCompile Include="CComponentDlg.cpp" />
    <ClCompile Include="CComponentPLCDlg.cpp" />
    <ClCompile Include="CPLC.cpp" />
    <ClCompile Include="AccordionWnd.cpp" />
    <ClCompile Include="Alarm.cpp" />
SourceCode/Bond/BondEq/BondEqDlg.cpp
@@ -74,6 +74,7 @@
    m_pMainContainer = nullptr;
    m_pHomeDialog = nullptr;
    m_pActiveView = nullptr;
    m_pActiveComponentDlg = nullptr;
}
void CBondEqDlg::DoDataExchange(CDataExchange* pDX)
@@ -134,7 +135,26 @@
                    }
                }
            }
            else if (RX_CODE_SELECT_COMPONENT == code) {
                CComponent* pComponent;
                if (pAny->getPtrValue("ptr", (void*&)pComponent)) {
                    if (pComponent->getClassName().compare("CPLC") == 0) {
                        if (m_pMainContainer != nullptr) {
                            if (m_pActiveComponentDlg != nullptr) {
                                if (m_pActiveComponentDlg->GetContext() != (void*)pComponent) {
                                    m_pActiveComponentDlg->DestroyWindow();
                                    delete m_pActiveComponentDlg;
                                    m_pActiveComponentDlg = nullptr;
                                }
                            }
                            if (m_pActiveComponentDlg == nullptr) {
                                m_pActiveComponentDlg = CreateComponentPLCDlg(pComponent);
                            }
                        }
                    }
                }
            }
            pAny->release();
        }, [&]() -> void {
            // onComplete
@@ -366,6 +386,12 @@
        m_pActiveView = nullptr;
    }
    if (m_pActiveComponentDlg != nullptr) {
        m_pActiveComponentDlg->DestroyWindow();
        delete m_pActiveComponentDlg;
        m_pActiveComponentDlg = nullptr;
    }
    if (m_hbrBkgnd != nullptr) {
        ::DeleteObject(m_hbrBkgnd);
    }
@@ -482,19 +508,18 @@
void CBondEqDlg::OnMenuFileSettings()
{
    /*
    CAxisSettingsDlg axisDlg;
    axisDlg.SetPLC(theApp.m_model.getBonder().getPLC("PLC(1)"));
    axisDlg.SetRecipeName(_T("Default"));
    axisDlg.DoModal();
    */
    // Cavity VacuumBake AfterBake AOI
    /*
    CIOMonitoringDlg dlg;
    dlg.SetIOManager("Cavity");
    dlg.SetPLC(theApp.m_model.getBonder().getPLC("PLC(1)"));
    dlg.DoModal();
    */
    /*
    CSettingsDlg dlg;
@@ -548,7 +573,7 @@
{
    int id = (int)lParam;
    if (id == VIEW_TOOL_BTN_CLOSE) {
        CloseView((CBaseView*)wParam);
        CloseView((CComponentDlg*)wParam);
    }
    return 0;
@@ -658,6 +683,14 @@
    m_pMainContainer->Resize();
}
void CBondEqDlg::CloseView(CComponentDlg* pView)
{
    pView->DestroyWindow();
    delete pView;
    m_pActiveComponentDlg = nullptr;
    m_pMainContainer->Resize();
}
CHomeDialog* CBondEqDlg::CreateHomeDlg()
{
    CHomeDialog* pDlg = new CHomeDialog(m_pMainContainer);
@@ -741,3 +774,27 @@
        m_pTopToolbar->SetOperatorBtnText(_T("未登录"));
    }
}
CComponentPLCDlg* CBondEqDlg::CreateComponentPLCDlg(CComponent* pComponent)
{
    CComponentPLCDlg* pDlg = new CComponentPLCDlg(m_pMainContainer);
    pDlg->Create(IDD_COMPONENT_PLC, m_pMainContainer);
    pDlg->SetContext(pComponent);
    CString strIcon0, strIcon1, strIcon2, strIcon3;
    strIcon0.Format(_T("%s\\Res\\small_close0.ico"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
    strIcon1.Format(_T("%s\\Res\\small_close1.ico"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
    strIcon2.Format(_T("%s\\Res\\small_close2.ico"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
    strIcon3.Format(_T("%s\\Res\\small_close3.ico"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
    pDlg->AddToolBtn(VIEW_TOOL_BTN_CLOSE,
        (LPTSTR)(LPCTSTR)strIcon0,
        (LPTSTR)(LPCTSTR)strIcon1,
        (LPTSTR)(LPCTSTR)strIcon2,
        (LPTSTR)(LPCTSTR)strIcon3, "关闭");
    pDlg->ShowWindow(SW_SHOW);
    pDlg->SetWindowText(pComponent->getName().c_str());
    m_pMainContainer->Resize();
    return pDlg;
}
SourceCode/Bond/BondEq/BondEqDlg.h
@@ -9,6 +9,7 @@
#include "CBaseView.h"
#include "CRemoteEqView.h"
#include "TopToolbar.h"
#include "CComponentPLCDlg.h"
// CBondEqDlg å¯¹è¯æ¡†
@@ -22,8 +23,10 @@
    void InitRxWindows();
    void Resize();
    void CloseView(CBaseView* pView);
    void CloseView(CComponentDlg* pView);
    CHomeDialog* CreateHomeDlg();
    CBaseView* CreateRemoteEqView(BEQ::IRemoteEquipment* pEquipment);
    CComponentPLCDlg* CreateComponentPLCDlg(CComponent* pComponent);
    void UpdateLoginStatus();
private:
@@ -35,7 +38,7 @@
    CPanelProject* m_pPanelProject;
    CHomeDialog* m_pHomeDialog;
    CBaseView* m_pActiveView;
    CComponentDlg* m_pActiveComponentDlg;
// å¯¹è¯æ¡†æ•°æ®
#ifdef AFX_DESIGN_TIME
SourceCode/Bond/BondEq/CComponentDlg.cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,415 @@
#include "stdafx.h"
#include "CComponentDlg.h"
#include "Common.h"
#define CAPTION_HEIGHT        36
#define CAPBTN                99
IMPLEMENT_DYNAMIC(CComponentDlg, CDialogEx)
CComponentDlg::CComponentDlg(UINT id, CWnd* pPage) : CDialogEx(id, pPage)
{
    m_crBkgnd = COMPONENT_DLG_BACKGROUND;
    m_hbrBkgnd = nullptr;
    m_pContext = nullptr;
    m_nState = 0;
    m_pHotBtn = nullptr;
    m_pPressBtn = nullptr;
}
CComponentDlg::~CComponentDlg()
{
}
BEGIN_MESSAGE_MAP(CComponentDlg, CDialogEx)
    ON_WM_CTLCOLOR()
    ON_WM_DESTROY()
    ON_WM_ACTIVATE()
    ON_WM_NCPAINT()
    ON_WM_MOUSEACTIVATE()
    ON_WM_SIZE()
    ON_WM_NCCALCSIZE()
    ON_WM_LBUTTONDOWN()
    ON_WM_NCHITTEST()
    ON_WM_NCMOUSEMOVE()
    ON_WM_NCLBUTTONDOWN()
    ON_WM_NCLBUTTONUP()
END_MESSAGE_MAP()
HBRUSH CComponentDlg::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 CComponentDlg::OnDestroy()
{
    CDialogEx::OnDestroy();
}
void CComponentDlg::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{
    CDialogEx::OnActivate(nState, pWndOther, bMinimized);
    if (WA_INACTIVE == nState) {
        OnApply();
    }
}
void CComponentDlg::OnNcPaint()
{
    // TODO: åœ¨æ­¤å¤„添加消息处理程序代码
    // ä¸ä¸ºç»˜å›¾æ¶ˆæ¯è°ƒç”¨ CDialogEx::OnNcPaint()
    RECT rect, rcClient;
    ::GetClientRect(m_hWnd, &rcClient);
    ::ClientToScreen(m_hWnd, (LPPOINT)&rcClient.left);
    ::ClientToScreen(m_hWnd, (LPPOINT)&rcClient.right);
    ::GetWindowRect(m_hWnd, &rect);
    ::OffsetRect(&rcClient, -rect.left, -rect.top);
    rect.right -= rect.left;
    rect.bottom -= rect.top;
    rect.left = 0;
    rect.top = 0;
    HRGN hRgnWnd = CreateRectRgnIndirect(&rect);
    HRGN hRgnClient = CreateRectRgnIndirect(&rcClient);
    HBRUSH hBrushBK, hBrushFrame;
    HDC hDC = ::GetWindowDC(m_hWnd);
    ::SelectClipRgn(hDC, hRgnWnd);
    ::ExtSelectClipRgn(hDC, hRgnClient, RGN_DIFF);
    // èƒŒæ™¯
    hBrushBK = CreateSolidBrush(m_crBkgnd);
    ::FillRect(hDC, &rect, hBrushBK);
    DeleteObject(hBrushBK);
    // æ ‡é¢˜æ ï¼Œæ–‡å­—,横线
    HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
    ::SelectObject(hDC, hFont);
    RECT rcCaption, rcText;
    rcCaption = rect;
    rcCaption.bottom = rcCaption.top + CAPTION_HEIGHT;
    rcText = rcCaption;
    rcText.left += 12;
    char szCaption[64];
    int nCaptionLen = GetWindowText(szCaption, 64);
    ::DrawText(hDC, szCaption, nCaptionLen, &rcText, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS);
    HPEN hPen = CreatePen(PS_SOLID, 1, RGB(222, 222, 222));
    HPEN hOldPen = (HPEN)::SelectObject(hDC, hPen);
    ::MoveToEx(hDC, 0, rcCaption.bottom, NULL);
    ::LineTo(hDC, rect.right, rcCaption.bottom);
    ::SelectObject(hDC, hOldPen);
    ::DeleteObject(hPen);
    // ç»˜åˆ¶æŒ‰é’®
    int y = (rcCaption.bottom - rcCaption.top - 24) / 2;
    int x = rcCaption.right - 12;
    for (auto& item : m_toolbtns) {
        if (item.hIcon != nullptr) {
            if (!item.bEnable) {
                DrawIconEx(hDC, x - 24, y,
                    item.hIcon[3], 24, 24, 0, 0, DI_NORMAL);
            }
            else if (m_pPressBtn == &item) {
                DrawIconEx(hDC, x - 24, y,
                    item.hIcon[2], 24, 24, 0, 0, DI_NORMAL);
            }
            else if (m_pHotBtn == &item) {
                DrawIconEx(hDC, x - 24, y,
                    item.hIcon[1], 24, 24, 0, 0, DI_NORMAL);
            }
            else {
                DrawIconEx(hDC, x - 24, y,
                    item.hIcon[0], 24, 24, 0, 0, DI_NORMAL);
            }
            x -= 24;
            x -= 3;
        }
    }
    hBrushFrame = CreateSolidBrush(RGB(255, 0, 0));
    // ::FrameRect(hDC, &rect, hBrushFrame);
    ::DeleteObject(hRgnWnd);
    ::DeleteObject(hRgnClient);
    DeleteObject(hBrushFrame);
    ::ReleaseDC(m_hWnd, hDC);
}
int CComponentDlg::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message)
{
    // TODO: åœ¨æ­¤æ·»åŠ æ¶ˆæ¯å¤„ç†ç¨‹åºä»£ç å’Œ/或调用默认值
    int nRet = CDialogEx::OnMouseActivate(pDesktopWnd, nHitTest, message);
    GetParent()->GetParent()->SendMessage(ID_MSG_VIEW_ACTIVE, (WPARAM)this, nRet);
    return nRet;
}
void CComponentDlg::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp)
{
    lpncsp->rgrc[0].top += (CAPTION_HEIGHT);
    CDialogEx::OnNcCalcSize(bCalcValidRects, lpncsp);
}
void CComponentDlg::SetContext(void* pContext)
{
    m_pContext = pContext;
}
void* CComponentDlg::GetContext()
{
    return m_pContext;
}
void CComponentDlg::OnApply()
{
}
void CComponentDlg::Show(CWnd* pParent, LPRECT lprcBtn)
{
    RECT rcClient, rcBox;
    pParent->GetClientRect(&rcClient);
    pParent->ClientToScreen(&rcClient);
    GetWindowRect(&rcBox);
    int x = lprcBtn->left;
    if (x + (rcBox.right - rcBox.left) > rcClient.right) {
        x = rcClient.right - (rcBox.right - rcBox.left);
    }
    SetWindowPos(NULL, x, lprcBtn->bottom + 2, 0, 0, SWP_NOSIZE);
    ShowWindow(SW_SHOW);
}
void CComponentDlg::OnViewActive()
{
    m_nState = 1;
    SendMessage(WM_NCPAINT, 0, 0);
}
void CComponentDlg::OnViewInactive()
{
    m_nState = 0;
    SendMessage(WM_NCPAINT, 0, 0);
}
void CComponentDlg::AddToolBtn(int id, const char* pszIcon0Path, const char* pszIcon1Path, const char* pszIcon2Path, const char* pszIcon3Path, const char* pszTooltip)
{
    TOOLBTN tb;
    memset(&tb, 0, sizeof(TOOLBTN));
    tb.id = id;
    tb.hIcon[0] = (HICON)::LoadImage(GetModuleHandle(NULL), pszIcon0Path, IMAGE_ICON, 24, 24,
        LR_LOADFROMFILE | LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
    tb.hIcon[1] = (HICON)::LoadImage(GetModuleHandle(NULL), pszIcon1Path, IMAGE_ICON, 24, 24,
        LR_LOADFROMFILE | LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
    tb.hIcon[2] = (HICON)::LoadImage(GetModuleHandle(NULL), pszIcon2Path, IMAGE_ICON, 24, 24,
        LR_LOADFROMFILE | LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
    tb.hIcon[3] = (HICON)::LoadImage(GetModuleHandle(NULL), pszIcon3Path, IMAGE_ICON, 24, 24,
        LR_LOADFROMFILE | LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
    strcpy_s(tb.szTooltip, 256, pszTooltip);
    tb.bEnable = TRUE;
    m_toolbtns.push_back(tb);
    EnableToolTips(TRUE);
}
void CComponentDlg::SetToolBtnEnable(int id, BOOL bEnable)
{
    CComponentDlg::TOOLBTN* pBtn = GetToolBtn(id);
    if (pBtn != nullptr) {
        pBtn->bEnable = bEnable;
        SendMessage(WM_NCPAINT);
    }
}
void CComponentDlg::SetToolBtnMenu(int id, HMENU hMenu)
{
    CComponentDlg::TOOLBTN* pBtn = GetToolBtn(id);
    if (pBtn != nullptr) {
        pBtn->hMenu = hMenu;
    }
}
void CComponentDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
    // TODO: åœ¨æ­¤æ·»åŠ æ¶ˆæ¯å¤„ç†ç¨‹åºä»£ç å’Œ/或调用默认值
    CDialogEx::OnLButtonDown(nFlags, point);
}
LRESULT CComponentDlg::OnNcHitTest(CPoint point)
{
    TOOLBTN* pBtn;
    LRESULT hit = MyHitTest(point, pBtn);
    if (hit == HTCAPTION || hit == CAPBTN) {
        return hit;
    }
    return CDialogEx::OnNcHitTest(point);
}
void CComponentDlg::OnNcMouseMove(UINT nHitTest, CPoint point)
{
    TOOLBTN* pLastHot = m_pHotBtn;
    int code = MyHitTest(point, m_pHotBtn);
    if (pLastHot != m_pHotBtn) {
        SendMessage(WM_NCPAINT, 0, 0);
    }
    CDialogEx::OnNcMouseMove(nHitTest, point);
}
void CComponentDlg::OnNcLButtonDown(UINT nHitTest, CPoint point)
{
    int code = MyHitTest(point, m_pPressBtn);
    SendMessage(WM_NCPAINT, 0, 0);
    GetParent()->GetParent()->SendMessage(ID_MSG_VIEW_ACTIVE, (WPARAM)this, MA_ACTIVATE);
    CDialogEx::OnNcLButtonDown(nHitTest, point);
}
void CComponentDlg::OnNcLButtonUp(UINT nHitTest, CPoint point)
{
    MyHitTest(point, m_pHotBtn);
    if (m_pPressBtn == m_pHotBtn && m_pPressBtn != nullptr && m_pPressBtn->bEnable) {
        if (m_pPressBtn->hMenu != nullptr) {
            int cmd = ::TrackPopupMenu(::GetSubMenu(m_pPressBtn->hMenu, 0),
                TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD,
                point.x, point.y + 2, 0, m_hWnd, NULL);
            GetParent()->GetParent()->PostMessage(ID_MSG_BTN_MENU_ITEM, (WPARAM)this, cmd);
        }
        else {
            GetParent()->GetParent()->PostMessage(ID_MSG_BTN_CLICKED, (WPARAM)this, m_pPressBtn->id);
        }
    }
    m_pPressBtn = nullptr;
    SendMessage(WM_NCPAINT, 0, 0);
    CDialogEx::OnNcLButtonUp(nHitTest, point);
}
int CComponentDlg::MyHitTest(POINT& point, TOOLBTN*& pBtn)
{
    RECT rcWnd, rcCaption;
    GetWindowRect(&rcWnd);
    LRESULT hit = HTNOWHERE;
    pBtn = nullptr;
    rcCaption.left = rcWnd.left + 2;
    rcCaption.right = rcWnd.right - 2;
    rcCaption.top = rcWnd.top += 2;
    rcCaption.bottom = rcCaption.top + 2 + CAPTION_HEIGHT;
    if (::PtInRect(&rcCaption, point)) {
        hit = HTCAPTION;
        RECT rcIcon;
        rcIcon.top = rcCaption.top + (rcCaption.bottom - rcCaption.top - 24) / 2;
        rcIcon.bottom = rcIcon.top + 24;
        rcIcon.right = rcCaption.right - 12;
        for (auto& item : m_toolbtns) {
            rcIcon.left = rcIcon.right - 24;
            if (::PtInRect(&rcIcon, point)) {
                pBtn = &item;
                hit = CAPBTN;
                break;
            }
            rcIcon.right = rcIcon.left - 3;
        }
    }
    return (int)hit;
}
CComponentDlg::TOOLBTN* CComponentDlg::GetToolBtn(int id)
{
    for (auto& item : m_toolbtns) {
        if (item.id == id) return &item;
    }
    return nullptr;
}
BOOL CComponentDlg::GetBtnRect(int id, LPRECT lprcBtn)
{
    RECT rcWnd, rcCaption;
    GetWindowRect(&rcWnd);
    ::OffsetRect(&rcWnd, -rcWnd.left, -rcWnd.top);
    rcCaption.left = rcWnd.left + 2;
    rcCaption.right = rcWnd.right - 2;
    rcCaption.top = rcWnd.top += 2;
    rcCaption.bottom = rcCaption.top + 2 + CAPTION_HEIGHT;
    lprcBtn->top = rcCaption.top + (rcCaption.bottom - rcCaption.top - 24) / 2;
    lprcBtn->bottom = lprcBtn->top + 24;
    lprcBtn->right = rcCaption.right - 12;
    for (auto& item : m_toolbtns) {
        lprcBtn->left = lprcBtn->right - 24;
        if (item.id == id) {
            return TRUE;
        }
        lprcBtn->right = lprcBtn->left - 3;
    }
    return FALSE;
}
INT_PTR CComponentDlg::OnToolHitTest(CPoint point, TOOLINFO* pTI) const
{
    RECT rcClient, rcCaption, rcBtn;
    ::GetClientRect(m_hWnd, &rcClient);
    rcCaption.bottom = 0;
    rcCaption.top = rcCaption.bottom - CAPTION_HEIGHT;
    rcCaption.left = rcClient.left;
    rcCaption.right = rcClient.right;
    rcBtn.top = rcCaption.top + (rcCaption.bottom - rcCaption.top - 24) / 2;
    rcBtn.bottom = rcBtn.top + 24;
    rcBtn.right = rcCaption.right - 12;
    ::OffsetRect(&rcBtn, +5, -5);        // 5为边框粗的修正
    if ((point.y <= 0)) {
        for (auto& item : m_toolbtns) {
            rcBtn.left = rcBtn.right - 24;
            if (::PtInRect(&rcBtn, point)) {
                pTI->rect = rcBtn;
                pTI->hwnd = m_hWnd;
                pTI->uId = (UINT)1020; // Tooltip should show `1020
                pTI->lpszText = _tcsdup(item.szTooltip);
                return pTI->uId;
            }
            rcBtn.right = rcBtn.left - 3;
        }
    }
    return CDialogEx::OnToolHitTest(point, pTI);
}
SourceCode/Bond/BondEq/CComponentDlg.h
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,73 @@
#pragma once
#define ID_MSG_VIEW_ACTIVE        WM_USER+2356
#define ID_MSG_BTN_CLICKED        WM_USER+2357
#define ID_MSG_BTN_MENU_ITEM    WM_USER+2358
class CComponentDlg : public CDialogEx
{
private:
    typedef struct _TOOLBTN
    {
        int id;
        HICON hIcon[4];
        char szTooltip[256];
        BOOL bEnable;
        HMENU hMenu;
    } TOOLBTN;
    DECLARE_DYNAMIC(CComponentDlg)
public:
    CComponentDlg(UINT id, CWnd* pPage);   // æ ‡å‡†æž„造函数
    virtual ~CComponentDlg();
public:
    void OnViewActive();
    void OnViewInactive();
    void AddToolBtn(int id, const char* pszIcon0Path, const char* pszIcon1Path, const char* pszIcon2Path, const char* pszIcon3Path, const char* pszTooltip);
    void SetToolBtnEnable(int id, BOOL bEnable);
    void SetToolBtnMenu(int id, HMENU hMenu);
    void Show(CWnd* pParent, LPRECT lprcBtn);
    void SetContext(void* pContext);
    void* GetContext();
    virtual void OnApply();
private:
    int MyHitTest(POINT& point, TOOLBTN*& pBtn);
    CComponentDlg::TOOLBTN* GetToolBtn(int id);
    BOOL GetBtnRect(int id, LPRECT lprcBtn);
private:
    std::vector<TOOLBTN> m_toolbtns;
    TOOLBTN* m_pHotBtn;
    TOOLBTN* m_pPressBtn;
    int m_nState;
protected:
    COLORREF m_crBkgnd;
    HBRUSH m_hbrBkgnd;
    void* m_pContext;
    DECLARE_MESSAGE_MAP()
public:
    afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
    afx_msg void OnDestroy();
    afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
    afx_msg void OnNcPaint();
    afx_msg int OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message);
    afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp);
    afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
    afx_msg LRESULT OnNcHitTest(CPoint point);
    afx_msg void OnNcMouseMove(UINT nHitTest, CPoint point);
    afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point);
    afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point);
    virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
};
SourceCode/Bond/BondEq/CComponentPLCDlg.cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,123 @@
// CComponentData1Dlg.cpp: å®žçŽ°æ–‡ä»¶
//
#include "stdafx.h"
#include "BondEq.h"
#include "CComponentPLCDlg.h"
#include "afxdialogex.h"
#include "Log.h"
#include "ToolUnits.h"
#include "Common.h"
// CComponentData1Dlg å¯¹è¯æ¡†
IMPLEMENT_DYNAMIC(CComponentPLCDlg, CComponentDlg)
CComponentPLCDlg::CComponentPLCDlg(CWnd* pParent /*=nullptr*/)
    : CComponentDlg(IDD_COMPONENT_PLC, pParent)
{
    m_pObserver = nullptr;
}
CComponentPLCDlg::~CComponentPLCDlg()
{
}
void CComponentPLCDlg::DoDataExchange(CDataExchange* pDX)
{
    CComponentDlg::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CComponentPLCDlg, CComponentDlg)
    ON_WM_CTLCOLOR()
    ON_WM_DESTROY()
    ON_WM_SIZE()
END_MESSAGE_MAP()
// CComponentData1Dlg æ¶ˆæ¯å¤„理程序
void CComponentPLCDlg::InitRxWindows()
{
    /* code */
    // è®¢é˜…数据
    IRxWindows* pRxWindows = RX_GetRxWindows();
    if (m_pObserver == NULL) {
        m_pObserver = pRxWindows->allocObserver([&](IAny* pAny) -> void {
            // onNext
            pAny->addRef();
            int code = pAny->getCode();
            if (RX_CODE_ALARM_EVENT == code) {
            }
            pAny->release();
            }, [&]() -> void {
                // onComplete
            }, [&](IThrowable* pThrowable) -> void {
                // onErrorm
                pThrowable->printf();
            });
        theApp.m_model.getObservable()->observeOn(pRxWindows->mainThread())
            ->subscribe(m_pObserver);
    }
}
BOOL CComponentPLCDlg::OnInitDialog()
{
    CComponentDlg::OnInitDialog();
    return TRUE;  // return TRUE unless you set the focus to a control
                  // å¼‚常: OCX å±žæ€§é¡µåº”返回 FALSE
}
HBRUSH CComponentPLCDlg::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 CComponentPLCDlg::OnDestroy()
{
    CComponentDlg::OnDestroy();
    if (m_hbrBkgnd != nullptr) {
        ::DeleteObject(m_hbrBkgnd);
    }
    if (m_pObserver != NULL) {
        m_pObserver->unsubscribe();
        m_pObserver = NULL;
    }
}
void CComponentPLCDlg::OnSize(UINT nType, int cx, int cy)
{
    CComponentDlg::OnSize(nType, cx, cy);
    //if (GetDlgItem(IDC_LIST_ALARM) == nullptr) return;
/*
    int y = 12;
    int x = 12;
    CRect rcClient, rcItem;
    CWnd* pItem;
    GetClientRect(&rcClient);
    pItem = GetDlgItem(IDC_LIST_ALARM);
    pItem->MoveWindow(x, y, rcClient.Width() - x - 12, rcClient.Height() - y - 12);
*/
}
SourceCode/Bond/BondEq/CComponentPLCDlg.h
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,37 @@
#pragma once
#include "CComponentDlg.h"
// CComponentPLCDlg å¯¹è¯æ¡†
class CComponentPLCDlg : public CComponentDlg
{
    DECLARE_DYNAMIC(CComponentPLCDlg)
public:
    CComponentPLCDlg(CWnd* pParent = nullptr);   // æ ‡å‡†æž„造函数
    virtual ~CComponentPLCDlg();
private:
    void InitRxWindows();
private:
    IObserver* m_pObserver;
// å¯¹è¯æ¡†æ•°æ®
#ifdef AFX_DESIGN_TIME
    enum { IDD = IDD_COMPONENT_ALARM };
#endif
protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV æ”¯æŒ
    DECLARE_MESSAGE_MAP()
public:
    virtual BOOL OnInitDialog();
    afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
    afx_msg void OnDestroy();
    afx_msg void OnSize(UINT nType, int cx, int cy);
};
SourceCode/Bond/BondEq/Common.h
@@ -73,6 +73,8 @@
#define TREE_BADGE2_BACKGROUND            RGB(255, 127, 39)
#define TREE_BADGE2_FOREGROUND            RGB(222, 222, 222)
#define HOMEPAGE_BACKGROUND                RGB(252, 252, 255)
#define COMPONENT_DLG_BACKGROUND        RGB(252, 252, 255)
#define COMPONENTS_PLC_BACKGROUND        RGB(0, 252, 255)
/* æŒ‰é’®é¢œè‰²å®šä¹‰ é£Žæ ¼1*/
SourceCode/Bond/BondEq/Resource.h
Binary files differ