MFC的cTreeCtrl控件

qq_41050020 2017-11-14 12:30:35
静态创建的控件请问默认是双击加号减号然后折叠和展开吗?
我现在的控件单击就可以折叠展开,而且是乱的,请问该问题该如何解决。
如何回归到默认状态。
...全文
142 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_41050020 2017-11-14
  • 打赏
  • 举报
回复
需求: 已经获取一个树,不对树做任何修改,只添加check box检查哪些选中。 然后查看了下默认双击折叠打开就行了 应该怎么弄?
zgl7903 2017-11-14
  • 打赏
  • 举报
回复
资源添加 TVS_CHECKBOXES 风格 既有CheckBox复选框 MSDN 上的例子

/*
Working with state image indexes
There is often confusion about how to set and retrieve the state image index in a tree view control. The following examples demonstrate the proper method for setting and retrieving the state image index. The examples assume that there are only two state image indexes in the tree view control, unchecked and checked. If your application contains more than two, these functions will need to be modified to handle that case. 

The following example function illustrates how to set an item's check state. 
*/
BOOL TreeView_SetCheckState(HWND hwndTreeView, HTREEITEM hItem, BOOL fCheck)
{
    TVITEM tvItem;

    tvItem.mask = TVIF_HANDLE | TVIF_STATE;
    tvItem.hItem = hItem;
    tvItem.stateMask = TVIS_STATEIMAGEMASK;

    /*
    Since state images are one-based, 1 in this macro turns the check off, and 
    2 turns it on.
    */
    tvItem.state = INDEXTOSTATEIMAGEMASK((fCheck ? 2 : 1));

    return TreeView_SetItem(hwndTreeView, &tvItem);
}


The following example function illustrates how to retrieve an item's check state. 

BOOL TreeView_GetCheckState(HWND hwndTreeView, HTREEITEM hItem)
{
    TVITEM tvItem;

    // Prepare to receive the desired information.
    tvItem.mask = TVIF_HANDLE | TVIF_STATE;
    tvItem.hItem = hItem;
    tvItem.stateMask = TVIS_STATEIMAGEMASK;

    // Request the information.
    TreeView_GetItem(hwndTreeView, &tvItem);

    // Return zero if it's not checked, or nonzero otherwise.
    return ((BOOL)(tvItem.state >> 12) -1);
}


15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧