chenluhua1980
2025-12-11 1958d1d4d370f80a0a664c08e60238919fc07a1c
1.事件页,增加三按钮;
已修改2个文件
31 ■■■■■ 文件已修改
SourceCode/Bond/Servo/CPageCollectionEvent.cpp 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CPageCollectionEvent.h 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CPageCollectionEvent.cpp
@@ -32,6 +32,7 @@
    ON_WM_CTLCOLOR()
    ON_WM_DESTROY()
    ON_WM_SIZE()
    ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST1, &CPageCollectionEvent::OnLvnItemchangedList1)
END_MESSAGE_MAP()
@@ -123,3 +124,30 @@
        m_listCtrl.SetItemText(index, 4, item->getReportIdsText().c_str());
    }
}
void CPageCollectionEvent::OnCreateBtns()
{
    const int BTN_W = 80;
    const int BTN_H = 28;
    CreateBtn(_T("新增"), BTN_W, BTN_H, 3001);
    CreateBtn(_T("删除"), BTN_W, BTN_H, 3002)->EnableWindow(FALSE);
    CreateBtn(_T("编辑"), BTN_W, BTN_H, 3003)->EnableWindow(FALSE);
}
void CPageCollectionEvent::OnLvnItemchangedList1(NMHDR* pNMHDR, LRESULT* pResult)
{
    LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
    int nSelCount = m_listCtrl.GetSelectedCount();
    if (CButton* pDel = GetBtnByName("删除")) {
        pDel->EnableWindow(nSelCount > 0);
    }
    if (CButton* pEdit = GetBtnByName("编辑")) {
        pEdit->EnableWindow(nSelCount > 0);
    }
    *pResult = 0;
}
void CPageCollectionEvent::OnClickedBtn(const char* btnName)
{
    // 暂留:后续实现增删改逻辑
}
SourceCode/Bond/Servo/CPageCollectionEvent.h
@@ -16,6 +16,8 @@
private:
    CListCtrlEx m_listCtrl;
    void OnCreateBtns() override;
    void OnClickedBtn(const char* btnName) override;
// 对话框数据
#ifdef AFX_DESIGN_TIME
@@ -31,4 +33,5 @@
    afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
    afx_msg void OnDestroy();
    afx_msg void OnSize(UINT nType, int cx, int cy);
    afx_msg void OnLvnItemchangedList1(NMHDR* pNMHDR, LRESULT* pResult);
};