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 |
---|---|
Constructs a CUserToolsManager. |
Public Methods
Name |
Description |
---|---|
Creates a new user tool. |
|
Returns the pointer to the CMFCUserTool object that is associated with a specified command ID. |
|
Returns the resource ID that is associated with the Arguments menu on the Tools tab of the Customize dialog box. |
|
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. |
|
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. |
|
Returns the resource ID that is associated with the Initial directory menu on the Tools tab of the Customize dialog box. |
|
Returns the maximum number of user tools that can be allocated in the application. |
|
Returns the command ID of the menu item placeholder for user tools. |
|
Returns a reference to the list of user tools. |
|
Executes an application associated with the user tool that has a specified command ID. |
|
Determines whether a command ID is associated with a user tool. |
|
Loads information about user tools from the Windows registry. |
|
Moves the specified user tool down in the list of user tools. |
|
Moves the specified user tool up in the list of user tools. |
|
Removes the specified user tool from the application. |
|
Stores information about user tools in the Windows registry. |
|
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. |
|
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
Requirements
Header: afxusertoolsmanager.h