| title | CMFCShellTreeCtrl Class | Microsoft Docs | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ms.custom | ||||||||||||||
| ms.date | 11/04/2016 | |||||||||||||
| ms.reviewer | ||||||||||||||
| ms.suite | ||||||||||||||
| ms.technology |
|
|||||||||||||
| ms.tgt_pltfrm | ||||||||||||||
| ms.topic | reference | |||||||||||||
| f1_keywords |
|
|||||||||||||
| dev_langs |
|
|||||||||||||
| helpviewer_keywords |
|
|||||||||||||
| ms.assetid | 3d1da715-9554-4ed7-968c-055c48146267 | |||||||||||||
| caps.latest.revision | 30 | |||||||||||||
| author | mikeblome | |||||||||||||
| ms.author | mblome | |||||||||||||
| manager | ghogen | |||||||||||||
| translation.priority.ht |
|
The CMFCShellTreeCtrl class extends CTreeCtrl Class functionality by displaying a hierarchy of Shell items.
[!INCLUDEcpp_fp_under_construction]
class CMFCShellTreeCtrl : public CTreeCtrl
| Name | Description |
|---|---|
| CMFCShellTreeCtrl::EnableShellContextMenu | Enables or disables the shortcut menu. |
| CMFCShellTreeCtrl::GetFlags | Returns a combination of flags that are passed to IShellFolder::EnumObjects. |
| CMFCShellTreeCtrl::GetItemPath | Retrieves the path to an item. |
| CMFCShellTreeCtrl::GetRelatedList | Returns a pointer to the CMFCShellListCtrl Class object that is used together with this CMFCShellTreeCtrl object to create an Explorer-like window. |
| CMFCShellTreeCtrl::OnChildNotify | This member function is called by this window's parent window when it receives a notification message that applies to this window. (Overrides CWnd::OnChildNotify.) |
| CMFCShellTreeCtrl::OnGetItemIcon | |
| CMFCShellTreeCtrl::OnGetItemText | |
| CMFCShellTreeCtrl::Refresh | Refreshes and repaints the current CMFCShellTreeCtrl object. |
| CMFCShellTreeCtrl::SelectPath | Selects the appropriate tree control item based on a supplied PIDL or string path. |
| CMFCShellTreeCtrl::SetFlags | Sets flags to filter the tree context (similar to the flags used by IShellFolder::EnumObjects). |
| CMFCShellTreeCtrl::SetRelatedList | Sets a relation between the current CMFCShellTreeCtrl object and a CMFCShellListCtrl object. |
This class extends the CTreeCtrl class by enabling your program to include Windows Shell items in the tree. This class can be associated with a CMFCShellListCtrl object to create a complete Explorer window. Then, selecting an item in the tree will display a list of Windows Shell items in the associated list.
CMFCShellTreeCtrl
Header: afxshelltreeCtrl.h
The following example demonstrates how to create an object of the CMFCShellTreeCtrl class. This code snippet is part of the Explorer sample.
[!code-cppNVC_MFC_Explorer#4]
[!code-cppNVC_MFC_Explorer#5]
Enables the shortcut menu.
void EnableShellContextMenu(BOOL bEnable = TRUE);
[in] bEnable
A Boolean that specifies whether to enable the shortcut menu.
Returns the flags set for the CMFCShellTreeCtrl Class object.
DWORD GetFlags() const;
A DWORD value that specifies the combination of flags currently set.
The flags set in the CMFCShellTreeCtrl are sent to the method IShellFolder::EnumObjects whenever the object is refreshed. You can change the flags with the CMFCShellTreeCtrl::SetFlags method.
Retrieves the path of an item in the CMFCShellTreeCtrl Class object.
BOOL GetItemPath(
CString& strPath,
HTREEITEM htreeItem = NULL) const;
[out] strPath
A reference to a string parameter. The method writes the path of the item to this parameter.
[in] htreeItem
The method retrieves the path for this tree control item.
Nonzero if successful; 0 otherwise.
If this method fails, strPath contains the empty string.
If you do not specify hTreeItem, this method tries to obtain the string for the currently selected item. If no item is selected and hTreeItem is NULL, this method fails.
Returns a pointer to the CMFCShellListCtrl Class object that is associated with this CMFCShellTreeCtrl object.
CMFCShellListCtrl* GetRelatedList() const;
A pointer to the CMFCShellListCtrl object that is associated with this tree control object.
By using a CMFCShellListCtrl object together with a CMFCShellTreeCtrl object, you can create an Explorer-like window. Use the method CMFCShellTreeCtrl::SetRelatedList to associate the two classes. After they are associated, the framework automatically updates the CMFCShellListCtrl if the selection in the CMFCShellTreeCtrl changes.
virtual BOOL OnChildNotify(
UINT message,
WPARAM wParam,
LPARAM lParam,
LRESULT* pLResult);
[in] message
[in] wParam
[in] lParam
[in] pLResult
virtual int OnGetItemIcon(
LPAFX_SHELLITEMINFO pItem,
BOOL bSelected);
[in] pItem
[in] bSelected
virtual CString OnGetItemText(LPAFX_SHELLITEMINFO pItem);
[in] pItem
Refreshes and repaints the CMFCShellTreeCtrl.
void Refresh();
Call this method to refresh the hierarchy of the items displayed in the CMFCShellTreeCtrl.
Selects an item in the CMFCShellTreeCtrl Class based on the supplied path.
BOOL SelectPath(LPCTSTR lpszPath);
BOOL SelectPath(LPCITEMIDLIST lpidl);
[in] lpszPath
A string that specifies the path of an item.
[in] lpidl
A PIDL that specifies the item
S_OK if successful; E_FAIL otherwise.
Sets flags to filter the tree context.
void SetFlags(
DWORD dwFlags,
BOOL bRefresh = TRUE);
[in] dwFlags
The flags to set.
[in] bRefresh
A Boolean that specifies whether the CMFCShellTreeCtrl should be refreshed immediately.
The CMFCShellTreeCtrl passes all set flags to IShellFolder::EnumObjects. For more information about the values of different flags, see IShellFolder::EnumObjects.
Associates a CMFCShellListCtrl object with a CMFCShellTreeCtrl object.
void SetRelatedList(CMFCShellListCtrl* pShellList);
[in] pShellList
A pointer to a CMFCShellListCtrl object.
This method associates a CMFCShellListCtrl with a CMFCShellTreeCtrl. These objects may be displayed as an Explorer-like window: if the user selects an object in the CMFCShellTreeCtrl, the associated items in the CMFCShellListCtrl will be automatically updated.
Use the method CMFCShellTreeCtrl::GetRelatedList to retrieve the CMFCShellListCtrl associated with a CMFCShellTreeCtrl.
Hierarchy Chart
Classes
CTreeCtrl Class
CMFCShellListCtrl Class