如何在ctree view 中改变tree 的风格?

depechemode 2001-12-14 07:26:24
树控制CTreeCtrl::Create的调用格式如下:

BOOL Create( DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID );

其中参数dwStyle用来确定树控制的类型;rect用来确定树控制的大小和位置;pParentWnd用来确定树控制的父窗口,通用是一个对话框并且不能为NULL;nID用来确定树控制的标识。树控制的风格可以是下列值的组合:
在C TREE VIEW 中,如何获得nID?

...全文
141 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
depechemode 2001-12-19
  • 打赏
  • 举报
回复
我已经知道了,感谢各位大哥
我是在 CTreeView中使用的
所以,
CTreeCtrl *p=GetTreeCtrl();
即可.
ZHENG017 2001-12-14
  • 打赏
  • 举报
回复
CTreeCtrl *pTree=&GetTreeCtrl();
SetWIndowLong(....)
dusb 2001-12-14
  • 打赏
  • 举报
回复
树型控件的nID是在资源模板中定义的,是个整形量,你可以直接引用
woodswoods 2001-12-14
  • 打赏
  • 举报
回复
CTreeCtrl::Create
BOOL Create( DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID );

Return Value

Nonzero if initialization was successful; otherwise 0.

Parameters

dwStyle

Specifies the tree view control’s style. Apply any combination of tree view control styles to the control.

rect

Specifies the tree view control’s size and position. It can be either a CRect object or aRECT structure.

pParentWnd

Specifies the tree view control’s parent window, usually a CDialog. It must not be NULL.

nID

Specifies the tree view control’s ID.

Remarks

If you specify the tree control in a dialog box template, or if you are using CTreeView, your tree control is created automatically when the dialog box or view is created. If you want to create the tree control as a child window of some other window, use the Create member function. If you create the tree control using Create, you must pass it WS_VISIBLE, in addition to other tree view styles.

You construct a CTreeCtrl in two steps. First call the constructor, then call Create, which creates the tree view control and attaches it to the CTreeCtrl object.

The following styles can be applied to a tree view control:

TVS_HASLINES The tree view control has lines linking child items to their corresponding parent items.


TVS_LINESATROOT The tree view control has lines linking child items to the root of the hierarchy.


TVS_HASBUTTONS The tree view control adds a button to the left of each parent item.


TVS_EDITLABELS The tree view control allows the user to edit the labels of tree view items.


TVS_SHOWSELALWAYS Causes a selected item to remain selected when the tree-view control loses focus.


TVS_DISABLEDRAGDROP The tree-view control is prevented from sending TVN_BEGINDRAG notification messages.


TVS_NOTOOLTIPS The tree view control uses no tooltips.


TVS_SINGLEEXPAND When this style is enabled, changing the selection in the tree view will automatically cause the item being selected to expand and the item being unselected to collapse. If the mouse is used to single-click the selected item and that item is closed, it will be expanded. If the selected item is single-clicked when it is open, it will be collapsed.
Example

// Assuming your window has a CTreeCtrl member named m_TreeCtrl,
// you can create the tree control window with a child ID of 0x1005
// using a call like this:

m_TreeCtrl->Create(WS_VISIBLE | WS_TABSTOP | WS_CHILD | WS_BORDER
| TVS_HASBUTTONS | TVS_LINESATROOT | TVS_HASLINES
| TVS_DISABLEDRAGDROP,
CRect(10, 10, 300, 100), this, 0x1005);

// The control will have the appropiate window styles, and the tree
// control styles specified are those most commonly used.

CTreeCtrl Overview | Class Members | Hierarchy Chart

See Also CTreeCtrl::CTreeCtrl,Tree View Control Window Styles in the Platform SDK


--------------------------------------------------------------------------------
Send feedback to MSDN.Look here for MSDN Online resources.
bluecrest 2001-12-14
  • 打赏
  • 举报
回复
nID是自己在resource.h中定义
或者在contrl中添加时,property设置

16,551

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

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