Partager via


CUserToolsManager Class

Maintains the collection of CUserTool Class objects in an application. A user tool is a menu item that runs an external application. The CUserToolsManager object enables the user or developer to add new user tools to the application. It supports the execution of the commands associated with user tools, and it also saves information about user tools in the Windows registry.

class CUserToolsManager : public CObject

Members

Public Constructors

Name

Description

CUserToolsManager::CUserToolsManager

Constructs a CUserToolsManager.

Public Methods

Name

Description

CUserToolsManager::CreateNewTool

Creates a new user tool.

CUserToolsManager::FindTool

Returns the pointer to the CMFCUserTool object that is associated with a specified command ID.

CUserToolsManager::GetArgumentsMenuID

Returns the resource ID that is associated with the Arguments menu on the Tools tab of the Customize dialog box.

CUserToolsManager::GetDefExt

Returns the default extension that the File Open dialog box (CFileDialog::CFileDialog) uses in the Command field on the Tools tab of the Customize dialog box.

CUserToolsManager::GetFilter

Returns the file filter that the File Open dialog box (CFileDialog Class) uses in the Command field on the Tools tab of the Customize dialog box.

CUserToolsManager::GetInitialDirMenuID

Returns the resource ID that is associated with the Initial directory menu on the Tools tab of the Customize dialog box.

CUserToolsManager::GetMaxTools

Returns the maximum number of user tools that can be allocated in the application.

CUserToolsManager::GetToolsEntryCmd

Returns the command ID of the menu item placeholder for user tools.

CUserToolsManager::GetUserTools

Returns a reference to the list of user tools.

CUserToolsManager::InvokeTool

Executes an application associated with the user tool that has a specified command ID.

CUserToolsManager::IsUserToolCmd

Determines whether a command ID is associated with a user tool.

CUserToolsManager::LoadState

Loads information about user tools from the Windows registry.

CUserToolsManager::MoveToolDown

Moves the specified user tool down in the list of user tools.

CUserToolsManager::MoveToolUp

Moves the specified user tool up in the list of user tools.

CUserToolsManager::RemoveTool

Removes the specified user tool from the application.

CUserToolsManager::SaveState

Stores information about user tools in the Windows registry.

CUserToolsManager::SetDefExt

Specifies the default extension that the File Open dialog box (CFileDialog Class) uses in the Command field on the Tools tab of the Customize dialog box.

CUserToolsManager::SetFilter

Specifies the file filter that the File Open dialog box (CFileDialog Class) uses in the Command field on the Tools tab of the Customize dialog box.

Remarks

To incorporate user tools into your application, you must:

1. Reserve a menu item and an associated command ID for a user tool menu entry.

2. Reserve a sequential command ID for each user tool that a user can define in your application.

3. Call the CWinAppEx::EnableUserTools method and supply the following parameters: menu command ID, first user tool command ID, and last user tool command ID.

There should be only one global CUserToolsManager object per application.

For an example of user tools, see the VisualStudioDemo sample project.

Example

The following example demonstrates how to retrieve a reference to a CUserToolsManager object and how to create new user tools. This code snippet is part of the Visual Studio Demo sample.

    CUserToolsManager* pUserToolsManager = theApp.GetUserToolsManager();
    if (pUserToolsManager != NULL && pUserToolsManager->GetUserTools().IsEmpty())
    {
        // CUserToolsManager* pUserToolsManager
        CUserTool* pTool1 = pUserToolsManager->CreateNewTool();
        pTool1->m_strLabel = _T("&Notepad");
        pTool1->SetCommand(_T("notepad.exe"));

        CUserTool* pTool2 = pUserToolsManager->CreateNewTool();
        pTool2->m_strLabel = _T("Paint &Brush");
        pTool2->SetCommand(_T("mspaint.exe"));

        CUserTool* pTool3 = pUserToolsManager->CreateNewTool();
        pTool3->m_strLabel = _T("&Windows Explorer");
        pTool3->SetCommand(_T("explorer.exe"));

        CUserTool* pTool4 = pUserToolsManager->CreateNewTool();
        pTool4->m_strLabel = _T("Microsoft On-&Line");
        pTool4->SetCommand(_T("https://www.microsoft.com"));
    }

Inheritance Hierarchy

CObject

   CUserToolsManager

Requirements

Header: afxusertoolsmanager.h

See Also

Reference

Hierarchy Chart

CWinAppEx Class

CUserTool Class

Other Resources

MFC Classes