- Main Page
- Namespaces
- Classes
- Files
- Directories

- Class List
- Class Hierarchy
- Class Members

# TreePropSheet::CTreePropSheet Class Reference

`#include <TreePropSheet.h>`

Inheritance diagram for TreePropSheet::CTreePropSheet:

List of all members.

## Public Member Functions
| CTreePropSheet ()
| CTreePropSheet (UINT nIDCaption, CWnd *pParentWnd=NULL, UINT iSelectPage=0)
| CTreePropSheet (LPCTSTR pszCaption, CWnd *pParentWnd=NULL, UINT iSelectPage=0)
virtual | ~CTreePropSheet ()
BOOL | SetTreeViewMode (BOOL bTreeViewMode=TRUE, BOOL bPageCaption=FALSE, BOOL bTreeImages=FALSE)
BOOL | SetTreeWidth (int nWidth)
void | SetEmptyPageText (LPCTSTR lpszEmptyPageText)
DWORD | SetEmptyPageTextFormat (DWORD dwFormat)
CTreeCtrl * | GetPageTreeControl ()
virtual BOOL | OnInitDialog ()
BOOL | SetTreeDefaultImages (CImageList *pImages)
BOOL | SetTreeDefaultImages (UINT unBitmapID, int cx, COLORREF crMask)
## Static Public Member Functions
static BOOL | DestroyPageIcon (CPropertyPage *pPage)
static BOOL | SetPageIcon (CPropertyPage *pPage, HICON hIcon)
static BOOL | SetPageIcon (CPropertyPage *pPage, UINT unIconId)
static BOOL | SetPageIcon (CPropertyPage *pPage, CImageList &Images, int nImage)
## Protected Member Functions
virtual CString | GenerateEmptyPageMessage (LPCTSTR lpszEmptyPageMessage, LPCTSTR lpszCaption)
virtual CTreeCtrl * | CreatePageTreeObject ()
virtual CPropPageFrame * | CreatePageFrame ()
void | MoveChildWindows (int nDx, int nDy)
void | RefillPageTree ()
HTREEITEM | CreatePageTreeItem (LPCTSTR lpszPath, HTREEITEM hParent=TVI_ROOT)
CString | SplitPageTreePath (CString &strRest)
BOOL | KillActiveCurrentPage ()
HTREEITEM | GetPageTreeItem (int nPage, HTREEITEM hRoot=TVI_ROOT)
BOOL | SelectPageTreeItem (int nPage)
BOOL | SelectCurrentPageTreeItem ()
void | UpdateCaption ()
void | ActivatePreviousPage ()
void | ActivateNextPage ()
afx_msg void | OnDestroy ()
afx_msg LRESULT | OnAddPage (WPARAM wParam, LPARAM lParam)
afx_msg LRESULT | OnRemovePage (WPARAM wParam, LPARAM lParam)
afx_msg LRESULT | OnSetCurSel (WPARAM wParam, LPARAM lParam)
afx_msg LRESULT | OnSetCurSelId (WPARAM wParam, LPARAM lParam)
afx_msg LRESULT | OnIsDialogMessage (WPARAM wParam, LPARAM lParam)
afx_msg void | OnPageTreeSelChanging (NMHDR *pNotifyStruct, LRESULT *plResult)
afx_msg void | OnPageTreeSelChanged (NMHDR *pNotifyStruct, LRESULT *plResult)

## Detailed Description

A property sheet, which can use a tree control instead of a tab control, to give the user access to the different pages.

You can use it exactly the same way, as a CPropertySheet object. Simply create CPropertyPage objects and add them via AddPage() to the sheet. If you would like to use the tree view mode (default), you can specify the path of the pages in the tree, by their name: The names of the pages can contain double colons ("::"), which will specify the path of that page in the tree control. I.e. if you have three pages with the following names: 1. _T("Appearance::Toolbars") 2. _T("Appearance::Menus") 3. _T("Directories") the tree would look as follow:

    Appearance
    |
    +-Toolbars
    |
    +-Menus

    Directories

If you would like to use a double colon, which should not be interpreted as a path seperator, prefix it with a backslash ("\\::").

To disable tree view mode and use the standard tabbed mode, call the SetTreeViewMode() method. This also allows you, to enable page captions and tree images for tree view mode. If you would like to have images in the tree, but not all of your pages specify images or there are tree view items, which are not attached to a page (only parent items for real page items), you have to set default images using the SetTreeDefaultImages() method -- otherwise their may appear display errors.

If the user selects a tree view item, which does not belong to a page, because it is just a parent item for real page items, no page will be displayed, instead a message will be displayed, that can be set via SetEmptyPageText().

Author:
  Sven Wiegand

Definition at line 80 of file TreePropSheet.h.

## Member Function Documentation

void TreePropSheet::CTreePropSheet::ActivateNextPage | ( |  | ) | `[protected]`

| Activates the next page in the page order or the first one, if the current one is the last. This method does never fail. Definition at line 667 of file TreePropSheet.cpp. Referenced by OnIsDialogMessage().

void TreePropSheet::CTreePropSheet::ActivatePreviousPage | ( |  | ) | `[protected]`

| Activates the previous page in the page order or the last one, if the current one is the first. This method does never fail. Definition at line 605 of file TreePropSheet.cpp. Referenced by OnIsDialogMessage().

CPropPageFrame * TreePropSheet::CTreePropSheet::CreatePageFrame | ( |  | ) | `[protected, virtual]`

| Will be called during creation process, to create the object, that is responsible for drawing the frame around the pages, drawing the empty page message and the caption. Allows you to inject your own CPropPageFrame-derived classes. This default implementation simply creates a CPropPageFrameTab with new and returns it. Definition at line 260 of file TreePropSheet.cpp.

HTREEITEM TreePropSheet::CTreePropSheet::CreatePageTreeItem | ( | LPCTSTR | lpszPath,
|  | HTREEITEM | hParent = `TVI_ROOT`
| ) | `[protected]`

  | Creates the specified path in the page tree and returns the handle of the most child item created. Parameters:
  | lpszPath | Path of the item to create (see description of this class).
  | hParentItem | Handle of the item under which the path should be created or TVI_ROOT to start from the root.
Definition at line 378 of file TreePropSheet.cpp. References SplitPageTreePath().

CTreeCtrl * TreePropSheet::CTreePropSheet::CreatePageTreeObject | ( |  | ) | `[protected, virtual]`

| Will be called during creation process, to create the CTreeCtrl object (the object, not the window!). Allows you to inject your own CTreeCtrl-derived classes. This default implementation simply creates a CTreeCtrl with new and returns it. Definition at line 254 of file TreePropSheet.cpp.

BOOL TreePropSheet::CTreePropSheet::DestroyPageIcon | ( | CPropertyPage * | pPage | ) | `[static]`

| Checks, if the PSP_USEHICON flag is set in the PROPSHEETPAGE struct; If this is the case, the flag will be removed and the icon specified by the hIcon attribute of the PROPSHEETPAGE struct will be destroyed using DestroyIcon(). Note: You only have to call DestroyIcon() for icons, that have been created using CreateIconIndirect() (i.e. used by CImageList::ExtractIcon()). Returns: TRUE on success, FALSE if the PSP_USEHICON flag was not set or if the icon handle was NULL. Definition at line 230 of file TreePropSheet.cpp.

CString TreePropSheet::CTreePropSheet::GenerateEmptyPageMessage | ( | LPCTSTR | lpszEmptyPageMessage,
|  | LPCTSTR | lpszCaption
| ) | `[protected, virtual]`

  | Will be called to generate the message, that should be displayed on an empty page, when the sheet is in tree view mode This default implementation simply returns lpszEmptyPageMessage with the optional "%s" placeholder replaced by lpszCaption. Parameters:
  | lpszEmptyPageMessage | The string, set by SetEmptyPageMessage(). This string may contain a "%s" placeholder.
  | lpszCaption | The title of the empty page.
Definition at line 246 of file TreePropSheet.cpp. Referenced by UpdateCaption().

CTreeCtrl * TreePropSheet::CTreePropSheet::GetPageTreeControl | ( |  | ) |

| Returns a pointer to the tree control, when the sheet is in tree view mode, NULL otherwise. Definition at line 193 of file TreePropSheet.cpp.

HTREEITEM TreePropSheet::CTreePropSheet::GetPageTreeItem | ( | int | nPage,
|  | HTREEITEM | hRoot = `TVI_ROOT`
| ) | `[protected]`

  | Returns the page tree item, that representates the specified page or NULL, if no such icon exists. Parameters:
  | nPage | Zero based page index, for which the item to retrieve.
  | hRoot | Item to start the search at or TVI_ROOT to search the whole tree.
Definition at line 482 of file TreePropSheet.cpp. Referenced by SelectPageTreeItem().

BOOL TreePropSheet::CTreePropSheet::KillActiveCurrentPage | ( |  | ) | `[protected]`

| Tries to deactivate the current page, and hides it if successfull, so that an empty page becomes visible. Returns: TRUE if the current page has been deactivated successfully, FALSE if the currently active page prevents a page change. Definition at line 451 of file TreePropSheet.cpp. Referenced by OnPageTreeSelChanging().

void TreePropSheet::CTreePropSheet::MoveChildWindows | ( | int | nDx,
|  | int | nDy
| ) | `[protected]`

  | Moves all childs by the specified amount of pixels. Parameters:
  | nDx | Pixels to move the childs in horizontal direction (can be negative).
  | nDy | Pixels to move the childs in vertical direction (can be negative).
Definition at line 269 of file TreePropSheet.cpp.

void TreePropSheet::CTreePropSheet::RefillPageTree | ( |  | ) | `[protected]`

| Refills the tree that contains the entries for the several pages. Definition at line 285 of file TreePropSheet.cpp. Referenced by OnAddPage(), and OnRemovePage().

BOOL TreePropSheet::CTreePropSheet::SelectCurrentPageTreeItem | ( |  | ) | `[protected]`

| Selects and shows the tree item for the currently active page. Returns: TRUE on success, FALSE if no item exists for the currently active page or if it was not possible to get information about the currently active page. Definition at line 533 of file TreePropSheet.cpp. References SelectPageTreeItem(). Referenced by OnAddPage(), OnRemovePage(), OnSetCurSel(), and OnSetCurSelId().

BOOL TreePropSheet::CTreePropSheet::SelectPageTreeItem | ( | int | nPage | ) | `[protected]`

  | Selects and shows the item, representing the specified page. Parameters:
  | nPage | Zero based page index.
Returns: TRUE on success, FALSE if no item does exist for the specified page. Definition at line 523 of file TreePropSheet.cpp. References GetPageTreeItem(). Referenced by SelectCurrentPageTreeItem().

void TreePropSheet::CTreePropSheet::SetEmptyPageText | ( | LPCTSTR | lpszEmptyPageText | ) |

| Specifies the text to be drawn on empty pages (pages for tree view items, that are not related to a page, because they are only parents for other items). This is only needed in tree view mode. The specified text can contains a single "%s" placeholder which will be replaced with the title of the empty page. Definition at line 142 of file TreePropSheet.cpp.

DWORD TreePropSheet::CTreePropSheet::SetEmptyPageTextFormat | ( | DWORD | dwFormat | ) |

  | Allows you to specify, how the empty page message (see SetEmptyPageText()) should be drawn. Parameters:
  | dwFormat | A combination of the DT_* flags available for the Win32-API function DrawText(), that should be used to draw the text. The default value is:
                      DT_CENTER|DT_VCENTER|DT_NOPREFIX|DT_SINGLELINE
Returns: The previous format. Definition at line 148 of file TreePropSheet.cpp. References TreePropSheet::CPropPageFrame::GetMsgFormat(), and TreePropSheet::CPropPageFrame::SetMsgFormat().

BOOL TreePropSheet::CTreePropSheet::SetPageIcon | ( | CPropertyPage * | pPage,
|  | HICON | hIcon
| ) | `[static]`

  | This helper allows you to easily set the icon of a property page. This static method does nothing more, than extracting the specified image as an icon from the given image list and assign the icon-handle to the hIcon property of the pages PROPSHEETPAGE structure (m_psp) and modify the structures flags, so that the image will be recognized. You need to call this method for a page, before adding the page to a property sheet. If you are using the CImageList-version, you are responsible for destroying the extracted icon with DestroyIcon() or the static DestroyPageIcon() method. See also: DestroyPageIcon() Parameters:
  | pPage | Property page to set the image for.
  | hIcon | Handle to icon that should be set for the page.
  | unIconId | Ressource identifier for the icon to set.
  | Images | Reference of the image list to extract the icon from.
  | nImage | Zero based index of the image in pImages, that should be used as an icon.
Returns: TRUE on success, FALSE if an error occured. Definition at line 202 of file TreePropSheet.cpp. Referenced by SetPageIcon().

BOOL TreePropSheet::CTreePropSheet::SetTreeDefaultImages | ( | CImageList * | pImages | ) |

  | Defines the images, that should be used for pages without icons and for empty parent nodes. The list contains exactly to images: 1. An image that should be used for parent tree nodes, without a page asignd. 2. An image that should be used for pages, which are not specifying any icons. Standard image size is 16x16 Pixels, but if you call this method before creating the sheet, the size of image 0 in this list will be assumed as your preferred image size and all other icons must have the same size. Parameters:
  | pImages | Pointer to an image list with exactly to images, that should be used as default images. The images are copied to an internal list, so that the given list can be deleted after this call.
  | unBitmapID | Resource identifier for the bitmap, that contains the default images. The resource should contain exactly to images.
  | cx | Width of a singe image in pixels.
  | crMask | Color that should be interpreted as transparent.
Returns: TRUE on success, FALSE otherwise. Definition at line 156 of file TreePropSheet.cpp.

BOOL TreePropSheet::CTreePropSheet::SetTreeViewMode | ( | BOOL | bTreeViewMode = `TRUE`,
|  | BOOL | bPageCaption = `FALSE`,
|  | BOOL | bTreeImages = `FALSE`
| ) |

  | Call this method, if you would like to use a tree control to browse the pages, instead of the tab control. This method needs to becalled, before DoModal() or Create(). If the window has already been created, the method will fail. Parameters:
  | bTreeViewMode | Pass TRUE to provide a tree view control instead of a tab control to browse the pages, pass FALSE to use the normal tab control.
  | bPageCaption | TRUE if a caption should be displayed for each page. The caption contains the page title and an icon if specified with the page. Ignored if bTreeViewMode is FALSE.
  | bTreeImages | TRUE if the page icons should be displayed in the page tree, FALSE if there should be no icons in the page tree. Ignored if bTreeViewMode is FALSE. If not all of your pages are containing icons, or if there will be empty pages (parent nodes without a related page, you need to call SetTreeDefaultImages() to avoid display errors.
Returns: TRUE on success or FALSE, if the window has already been created. Definition at line 107 of file TreePropSheet.cpp.

BOOL TreePropSheet::CTreePropSheet::SetTreeWidth | ( | int | nWidth | ) |

  | Specifies the width of the tree control, when the sheet is in tree view mode. The default value (if this method is not called) is 150 pixels. This method needs to be called, before DoModeal() or Create(). Otherwise it will fail. Parameters:
  | nWidth | The width in pixels for the page tree.
Returns: TRUE on success, FALSE otherwise (if the window has already been created). Definition at line 127 of file TreePropSheet.cpp.

CString TreePropSheet::CTreePropSheet::SplitPageTreePath | ( | CString & | strRest | ) | `[protected]`

| Splits the given path into the topmost item and the rest. See description of this class for detailed path information. I.e. when given the string "Appearance::Toolbars::Customize", the method will return "Appearance" and after the call strRest will be "Toolbars::Customize". Definition at line 418 of file TreePropSheet.cpp. Referenced by CreatePageTreeItem().

void TreePropSheet::CTreePropSheet::UpdateCaption | ( |  | ) | `[protected]`

| Updates the caption for the currently selected page (if the caption is enabled). Definition at line 543 of file TreePropSheet.cpp. References GenerateEmptyPageMessage(), TreePropSheet::CPropPageFrame::GetShowCaption(), TreePropSheet::CPropPageFrame::SetCaption(), and TreePropSheet::CPropPageFrame::SetMsgText(). Referenced by OnPageTreeSelChanged(), OnSetCurSel(), and OnSetCurSelId().

The documentation for this class was generated from the following files:

- C:/guliverkli/src/ui/TreePropSheet/TreePropSheet.h
- C:/guliverkli/src/ui/TreePropSheet/TreePropSheet.cpp