Visual Basic | |
---|---|
Public Interface IUserCommand |
C# | |
---|---|
public interface IUserCommand |
JavaScript | |
---|---|
Object dsUserCommand |
COM native C++ | |
---|---|
interface IUserCommand |
C++ | |
---|---|
class dsUserCommand |
The following code snippets show how to add a command to list of available commands:
- COM native C++ (from the DraftSight API COM native C++ template files DsAddinUserCommand.h, DsAddinConnection.cpp, and DsAddinUserCommand.cpp)
- C++ (from the DraftSight API C++ template file dsAddinConnection.cpp)
COM native C++
DsAddinUserCommand.h
private:
CComQIPtr<IUserCommand> m_DsUserCommand;
DsAddinConnection.cpp
DsAddinUserCommand pNotepad(m_sApiUuid, L"Notepad", L"^C^CNotepad", L"Opens Notepad", L"path_and_file_name.bmp", L"path_and_file_name.png");
DsAddinUserCommand.cpp
// DsAddinUserCommand constructor
DsAddinUserCommand::DsAddinUserCommand( _bstr_t ApiUuid, _bstr_t UserCmdName, _bstr_t CmdString, _bstr_t Description, _bstr_t SmallIcon, _bstr_t LargeIcon ){
CDsAddinConnection *dsConnection = getMyApp();
dsCreateCommandError_e commandErr;
// User command dependent on pre-defined command
ICommand* pCommand = dsConnection->m_DsApp->CreateCommand( ApiUuid, UserCmdName, &commandErr );
m_DsUserCommand = dsConnection->m_DsApp->CreateUserCommand( ApiUuid, UserCmdName, CmdString, Description, SmallIcon, LargeIcon, &commandErr );
}
C++
bool
myApplication::CreateUserInterfaceAndCommands(){
dsString emptyStr = L"";
dsString UserCommandName = L"qAddin1_Notepad";
dsString Description = L"Opens Notepad";
dsString UserCmdString = L"^C^CqAddin1_Notepad";
const int MENU_POSITION = 9; //Menu should be between "Modify" and "Tools" menus
dsApplication_c *dsApp = getDsApp();
dsCreateCommandError_e Error;
// User command dependent on pre-defined command
dsApp->CreateCommand(myApplication::appID, UserCommandName, &Error, &pCmd );
if(( Error == 0 ) )
{
RegisterCommandExecuteNotifyHook( pCmd );
dsUserCommand_ptr pUserCmd;
dsApp->CreateUserCommand( myApplication::appID, UserCommandName, UserCmdString, Description, L"path_and_file_name.bmp", L"path_and_file_name.png", dsUIState_Document, &Error, &pUserCmd );
Create Context-sensitive Menu Items (VB.NET)
Create Context-sensitive Menu Items (VBA)
To see a list of existing commands:
- Right-click a toolbar in the user interface.
- Select Customize Interface.
- Click Commands on the left side of the dialog.
- Use the scroll bar to see the list of existing commands.
- To quickly locate a command that you've added:
- Type the name of the command in Find.
- Click the name of the command in the Name column.
- Examine the information at the bottom of the dialog.