MFC 树控件之Create函数说明

MFC 树控件之Create函数说明

原文转自:http://chenfeie.st.dprktimes.com/vc/_mfc_ctreectrl.3a3a.create.htm

CTreeCtrl::Create

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

返回值

Nonzero if initialization was successful; otherwise 0.

如果初始化成功则返回非零值;否则返回0

参数说明

dwStyle

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

指定tree view控件的风格。可以对这个控件使用tree view控件风格的任意组合。

rect

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

指定tree view控件的尺寸和位置。此参数可以是一个CRect对象或一个RECT结构。

pParentWnd

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

指定tree view控件的父窗口,通常是一个CDialog。它不能是NULL。

nID

Specifies the tree view control’s ID.

指定tree view控件的ID。

备注

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.

构造一个CTreeCtrl要分两步。首先调用构造函数,然后调用Create来创建这个tree view控件并将它与该CTeeCtrl对象连接

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

下面的风格可以应用到一个tree view控件

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

    TVS_HASLINES tree view控件的子项与它们的父项之间用线连接。
  • TVS_LINESATROOT   The tree view control has lines linking child items to the root of the hierarchy.

    TVS_LINESATROOT tree view控件用线连接子项和根项。
  • TVS_HASBUTTONS   The tree view control adds a button to the left of each parent item.

    TVS_HASBUTTONS tree view在每一个父项的左边添加一个按钮。
  • TVS_EDITLABELS   The tree view control allows the user to edit the labels of tree view items.

    TVS_EDITLABELS tree view控件允许用户编辑tree view项的标签。
  • TVS_SHOWSELALWAYS   Causes a selected item to remain selected when the tree-view control loses focus.

    TVS_SHOWSELALWAYS 当tree view失去焦点时,使被选择的项仍然保持被选择
  • TVS_DISABLEDRAGDROP   The tree-view control is prevented from  sending TVN_BEGINDRAG notification messages.

    TVS_DISABLEDRAGDROP 该tree view控件被禁止发送TVN_BEGINDRAG通知消息。
  • TVS_NOTOOLTIPS   The tree view control uses no tooltips.

    TVS_NOTOOLTIPS tree view控件使用工具提示。
  • 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.

    TVS_SINGLEEXPAND 当使用这个风格时,改变在tree view中的选择将导致正被选择的项展开,而没有被选择的项收缩。如果用鼠标单击被选择的项,并且该项是关闭的,则该项就会展开。如果该被选择的项被单击时是打开的,则它就会收缩。

你可能感兴趣的:(MFC 树控件之Create函数说明)