Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

The Ultimate Toolbox Shell Related Classes

0.00/5 (No votes)
24 Aug 2007 1  
The Ultimate Toolbox classes for Shell Namespace navigation, an Application Bar, and more

Visit the Ultimate Toolbox main page for an overview and configuration guide to the Ultimate Toolbox library.

Contents

Introduction

The following classes deal mainly with the areas of the shell namespace, links, app and task bars etc.

Links


The Static Hyperlink sample in action.

COXHyperLinkAction class is to some extent a wrapper around the ShellExecute function.

See the Static Hyperlink article for more on this class and its usage.

Application Bar

The COXAppBar class provides the functionality of a Windows shell application bar.


The MultiClipboard example in the samples\utility\ClipDock directory is implemented as an application bar.

Typically you will derive a class from an instance of the template class after designing the dialog that will be used in the application bar:

class CMyApplicationBarDlg : public COXAppBar<CDialog> {...}

Then in your constructors initialization list you will initialize the base class with the dialog ID and parent window:

CMyApplicationBarDlg::CMyApplicationBarDlg(CWnd* pParent /*=NULL*/)
: COXAppBar<CDialog>(CMyApplicationBarDlg::IDD, pParent)
{

}

To start using your class just call Register(TRUE), which registers/unregisters the app bar with the windows shell.

Shell Namespace

COXShellFolderTree, COXShellNamespaceNavigator, and COXShellObjectList allow for iterating and viewing the namespace aspects of the Windows shell.


The COXShellFolderTree in action as part of a directory picker combo in the samples\gui\ComboTree example.

In this sample, the CFolderTree class is declared as a COXTreeComboDropdown using COXShellFolderTree:

class CFolderTree : public COXTreeComboDropDown<COXShellFolderTree>  
{
public:
     CFolderTree();
     virtual BOOL CanSelectItem(HTREEITEM hItem);
     virtual ~CFolderTree();
     virtual CString GetSelectedItemText();
};

This class is then declared as a member and created directly - it is then paired with the CComboBox extension class COXComboPickerCtrl to act as the dropdown portion of the control:

// Implementation

protected:
    COXComboPickerCtrl m_pckShell;
    CFolderTree m_cmbShell;

    //initializing shell tree

    VERIFY(m_pckShell.Create(WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED | 
        CBS_DROPDOWNLIST, 
        CRect(20,30,160,40),this,IDC_PICKER));
    VERIFY(m_cmbShell.Create(WS_CHILD | TVS_HASBUTTONS | TVS_TRACKSELECT | 
        TVS_LINESATROOT | TVS_HASLINES,
        CRect(0,0,0,0),this,IDC_COMBO));

    m_cmbShell.SetOwnerCombo(&m_pckShell);
    m_pckShell.AttachDropDown(&m_cmbShell);
    m_pckShell.SetMaxDropdownHeight(200);
    m_cmbShell.InitializeTree();        // this will initialize the namespace 

                                        // tree beginning with the desktop 

                                        // folder (default)

    ...

Shortcut

COXShortcut provides a wrapper for the IShellLink and IPersistFile interfaces.

The demo simply exercises the COX Shortcut m_scDemo object once opened, calling the specified interfaces:

        ...
        CASE(FN_GETARGUMENTS)
            if (bSuccess == m_scDemo.GetArguments(sBuffer))
                m_sOutput.Format(fmtS, sBuffer);
        
        CASE(FN_GETCURFILE)
            sBuffer = m_scDemo.GetCurFile();
            m_sOutput.Format(fmtS, sBuffer);

        CASE(FN_GETDESCRIPTION)
            if (bSuccess == m_scDemo.GetDescription(sBuffer))
                m_sOutput.Format(fmtS, sBuffer);
        ...

Taskbar

The COXTaskbarIcon class encapsulates Win32 API's Shell_NotifyIcon() function to let you easily show, hide, or change icons in Window 95's or Windows NT's taskbar notification area.

See the Taskbar Icon article for more on this class and its usage.

History

Initial CodeProject release August 2007.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here