Delen via


CUserTool Class

A user tool is a menu item that runs an external application. The Tools tab of the Customize dialog box (CMFCToolBarsCustomizeDialog Class) enables the user to add user tools, and to specify the name, command, arguments, and initial directory for each user tool.

class CUserTool : public CObject

Members

Public Methods

Name

Description

CUserTool::CopyIconToClipboard

 

CUserTool::DrawToolIcon

Draws the user tool icon in a specified rectangle.

CUserTool::GetCommand

Returns a string that contains the text of the command associated with the user tool.

CUserTool::GetCommandId

Returns the command ID of the menu item of the user tool.

CUserTool::Invoke

Executes the command associated with the user tool.

CUserTool::Serialize

Reads or writes this object from or to an archive. (Overrides CObject::Serialize.)

CUserTool::SetCommand

Sets the command associated with the user tool.

CUserTool::SetToolIcon

Loads the icon for the user tool from the application associated with the tool.

Protected Methods

Name

Description

CUserTool::LoadDefaultIcon

Loads the default icon for a user tool.

Data Members

Name

Description

CUserTool::m_strArguments

The command-line arguments for the user tool.

CUserTool::m_strInitialDirectory

The initial directory for the user tool.

CUserTool::m_strLabel

The tool name that is displayed in the menu item for the tool.

Remarks

For more information about how to enable user tools in your application, see CUserToolsManager Class.

Example

The following example demonstrates how to create a tool from a CUserToolsManager object, set the m_strLabel member variable, and set the application that the user tool runs. This code snippet is part of the Visual Studio Demo sample.

// CUserToolsManager* pUserToolsManager
        CUserTool* pTool1 = pUserToolsManager->CreateNewTool();
        pTool1->m_strLabel = _T("&Notepad");
        pTool1->SetCommand(_T("notepad.exe"));

Inheritance Hierarchy

CObject

   CUserTool

Requirements

Header: afxusertool.h

See Also

Reference

Hierarchy Chart

CWinAppEx Class

CUserToolsManager Class

Other Resources

MFC Classes