LAPTOP-SNT8I5JK\Boounion
2025-08-21 c5ef06019f738d92e01a664e7b1354ba2accb9a6
1.完善可折叠列表;
已修改4个文件
62 ■■■■■ 文件已修改
SourceCode/Bond/Servo/CControlJobDlg.cpp 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CExpandableListCtrl.cpp 43 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CExpandableListCtrl.h 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/Servo.rc 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CControlJobDlg.cpp
@@ -39,12 +39,6 @@
{
    CDialogEx::OnInitDialog();
    DWORD dwStyle = m_listCtrl.GetExtendedStyle();
    dwStyle |= LVS_EX_FULLROWSELECT;
    dwStyle |= LVS_EX_GRIDLINES;
    dwStyle |= LVS_EX_DOUBLEBUFFER;
    m_listCtrl.SetExtendedStyle(dwStyle);
    HIMAGELIST imageList = ImageList_Create(24, 24, ILC_COLOR24, 1, 1);
    ListView_SetImageList(m_listCtrl.GetSafeHwnd(), imageList, LVSIL_SMALL);
@@ -64,8 +58,8 @@
    m_listCtrl.InsertChild(ch21, { _T("SubStep A2"), _T("Run"),  _T("Bond") });
    // 初始让顶层展开
    //root1->expanded = true;
    //root2->expanded = true;
    root1->expanded = true;
    root2->expanded = true;
    m_listCtrl.RebuildVisible();
SourceCode/Bond/Servo/CExpandableListCtrl.cpp
@@ -19,16 +19,18 @@
    // 报表风格列举例
    SetExtendedStyle(GetExtendedStyle()
        | LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP | LVS_EX_GRIDLINES);
    // 示例列(可在外部设置)
    if (GetHeaderCtrl() == nullptr || GetHeaderCtrl()->GetItemCount() == 0) {
        InsertColumn(0, _T("名称"), LVCFMT_LEFT, 260);
        InsertColumn(1, _T("状态"), LVCFMT_LEFT, 120);
        InsertColumn(2, _T("描述"), LVCFMT_LEFT, 260);
    }
        | LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP | LVS_EX_GRIDLINES | LVS_EX_DOUBLEBUFFER);
    return 0;
}
void CExpandableListCtrl::PreSubclassWindow()
{
    // 报表风格列举例
    SetExtendedStyle(GetExtendedStyle()
        | LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP | LVS_EX_GRIDLINES | LVS_EX_DOUBLEBUFFER);
    CListCtrl::PreSubclassWindow();
}
CExpandableListCtrl::Node* CExpandableListCtrl::InsertRoot(const std::vector<CString>& cols)
@@ -273,6 +275,29 @@
            CString txt0 = n->cols.empty() ? _T("") : n->cols[0];
            pDC->DrawText(txt0, textRc, DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_END_ELLIPSIS);
            // —— 画完三角与文本之后,补一条该行的底部横向网格线 ——
            // 仅当开启了 LVS_EX_GRIDLINES 才绘制
            if (GetExtendedStyle() & LVS_EX_GRIDLINES)
            {
                // 用整行 bounds,保证横线贯穿所有列的可见宽度
                CRect rcRow;
                GetSubItemRect(row, 0, LVIR_BOUNDS, rcRow);
                // 底边 y 坐标(与系统网格线对齐)
                const int y = rcRow.bottom - 1;
                // 颜色与系统风格接近;若觉得偏浅,可换 COLOR_3DSHADOW
                CPen pen(PS_SOLID, 1, GetSysColor(COLOR_3DLIGHT));
                CPen* oldPen = pDC->SelectObject(&pen);
                // 横线从行左到行右(当前可见区域)
                pDC->MoveTo(rcRow.left, y);
                pDC->LineTo(rcRow.right, y);
                pDC->SelectObject(oldPen);
            }
            *pResult = CDRF_SKIPDEFAULT;
            return;
        }
@@ -286,5 +311,3 @@
    *pResult = CDRF_DODEFAULT;
}
SourceCode/Bond/Servo/CExpandableListCtrl.h
@@ -35,12 +35,16 @@
    // 便捷:通过可见行号取 Node*
    Node* GetNodeByVisibleIndex(int i) const;
private:
    void appendVisible(Node* n);
    CRect expanderRectForRow(int row) const;        // 首列展开按钮区域
    virtual void PreSubclassWindow();
protected:
    // 消息
    afx_msg int  OnCreate(LPCREATESTRUCT lpCreateStruct);
    afx_msg void OnClick(NMHDR* pNMHDR, LRESULT* pResult);
    afx_msg void OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult);
    DECLARE_MESSAGE_MAP()
private:
@@ -49,9 +53,6 @@
    int  m_expanderPadding = 6;   // 首列内侧边距
    int  m_expanderSize = 10;  // 小三角/方块大小
    int  m_textGap = 6;
    void appendVisible(Node* n);
    CRect expanderRectForRow(int row) const; // 首列展开按钮区域
};
SourceCode/Bond/Servo/Servo.rc
Binary files differ