Professional UI Solutions
Site Map   /  Register


Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » A simple way to specify root for CExtShellDialogBrowseFor Collapse All
Subject Author Date
David Skok Apr 8, 2009 - 6:33 AM

I would like to implement CExtShellDialogBrowseFor in my app.  How can I set the root directory to a known location given a lpsz string or CString?  I look at the ProfUIS_Controls sample and this uses another browse for path search and I am lost as to how to specify it directly.

When this known directory is browsed, is it possible to filter the items in the directory based on their extension?  The root directory that I set will contain directories with known extensions.

Technical Support Apr 8, 2009 - 1:24 PM

You should initialize the CExtShellDialogBrowseFor::m_pidlRoot property before calling the dialog’s DoModal() method:

CExtShellDialogBrowseFor dlg( . . . );
            . . .
HWND hWndParentForMsgBoxex = ::AfxGetMainWnd()->GetSafeHwnd();
            if( ! dlg.m_pidlRoot.FromFolder( _T("C:\\Your\\Folder\\Path\\Here"), hWndParentForMsgBoxex ) )
                        return . . . // incorrect folder path
            . . .
INT nRetVal = dlg.DoModal();
            . . .
There are two overloaded versions of the CExtPIDL::FromFolder() method:
   bool FromFolder( __EXT_MFC_SAFE_LPCTSTR pszPath, HWND hWndOwner );
            bool FromFolder( UINT nSpecialFolder, HWND hWndOwner );
The first is used in the code snippet above and allows you to point the CExtPIDL object to the specified folder on the file system. The second enables you to create a CExtPIDL object referred to the standard shell folder and its first parameter is one of the CSIDL_*** constants defined in the SHLOBJ.H file.

David Skok Apr 9, 2009 - 9:41 AM

Thank you for the quick response, setting the root directory directly works well.

I would like to implement a filter for the items displayed in the CExtShellDialogBrowseFor tree.  I looked at the documentation and source and there diesn’t seem to be anything that supports this.  Am I missing something?

SHBrowseForFolder implements such a function using a callback although I’ve never tried it.

Technical Support Apr 9, 2009 - 11:54 AM

The CExtShellDialogBrowseFor:: m_wndShellTree public property is the CExtShellTreeCtrl shell tree control used in the browse for folder dialog. The CExtShellTreeCtrl class has the following public properties for filtering displayed shell items:

	DWORD m_dwAttributeFilterAny, m_dwAttributeFilterAllPresent, m_dwAttributeFilterAllAbsent;

Each property contains combination of the SFGAO_*** flags for filtering shell items in the tree:
// IShellFolder::GetAttributesOf flags
#define SFGAO_CANCOPY           DROPEFFECT_COPY // Objects can be copied
#define SFGAO_CANMOVE           DROPEFFECT_MOVE // Objects can be moved
#define SFGAO_CANLINK           DROPEFFECT_LINK // Objects can be linked
#define SFGAO_CANRENAME         0x00000010L     // Objects can be renamed
#define SFGAO_CANDELETE         0x00000020L     // Objects can be deleted
#define SFGAO_HASPROPSHEET      0x00000040L     // Objects have property sheets
#define SFGAO_DROPTARGET        0x00000100L     // Objects are drop target
#define SFGAO_CAPABILITYMASK    0x00000177L
#define SFGAO_LINK              0x00010000L     // Shortcut (link)
#define SFGAO_SHARE             0x00020000L     // shared
#define SFGAO_READONLY          0x00040000L     // read-only
#define SFGAO_GHOSTED           0x00080000L     // ghosted icon
#define SFGAO_HIDDEN            0x00080000L     // hidden object
#define SFGAO_FILESYSANCESTOR   0x10000000L     // It contains file system folder
#define SFGAO_FOLDER            0x20000000L     // It’s a folder.
#define SFGAO_FILESYSTEM        0x40000000L     // is a file system thing (file/folder/root)
#define SFGAO_HASSUBFOLDER      0x80000000L     // Expandable in the map pane
#define SFGAO_CONTENTSMASK      0x80000000L
#define SFGAO_VALIDATE          0x01000000L     // invalidate cached information
#define SFGAO_REMOVABLE         0x02000000L     // is this removeable media?
#define SFGAO_COMPRESSED        0x04000000L     // Object is compressed (use alt color)
#define SFGAO_BROWSABLE         0x08000000L     // is in-place browsable
#define SFGAO_NONENUMERATED     0x00100000L     // is a non-enumerated object
#define SFGAO_NEWCONTENT        0x00200000L     // should show bold in explorer tree

Is that what you need?