GetID Method (IMenuItem) Send Feedback
See Also 
ID[out]
ID of the menu item
Gets the ID of the menu item.

Syntax

Visual Basic 
Function GetID() As System.String
C# 
System.string GetID()
JavaScript 
GetID() : String
COM native C++ 
HRESULT GetID(
   BSTR* ID
)  
C++ 
DSRESULT GetID(
   dsString* ID
)  

Parameters

ID[out] or Return Value
ID of the menu item

Example

This code snippet shows how to add user commands, a menu, menu item, toolbar, and toolbar button to the DraftSight user interface (from the DraftSight API C++ template file dsAddinConnection.cpp). 

C++

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 );

dsMenuItem_ptr pMenu;

dsApp->AddMenu(myApplication::appID, dsUIState_Document, MENU_POSITION, UserCommandName, &pMenu);

dsString UserCmdID1;

pUserCmd->GetID( &UserCmdID1 );

dsMenuItem_ptr pMenuItem;

pMenu->InsertMenuItem(myApplication::appID, dsMenuItemType_UserCommand, 1, L"Open Notepad", UserCmdID1, &pMenu);

if( ( dsCreateCommand_Succeeded == Error ) && ( NULL != pUserCmd ) )

{

dsString ToolbarName = L"QAddIn1_Toolbar";

dsToolbar_ptr pToolbar;

dsApp->AddToolbar( myApplication::appID, dsUIState_Document, ToolbarName, &pToolbar );

if( NULL != pToolbar )

 

{

dsToolbarItem_ptr pToolbarItem;

dsString ButtonName = L"Notepad";

dsString UserCmdID;

pMenu->GetID( &UserCmdID );

pToolbar->InsertToolbarItem( myApplication::appID, dsToolBarItemType_UserCommand, 1, ButtonName, UserCmdID, &pToolbarItem );

}

}

Remarks

The return value is the string specified for IMenuItem::InsertMenuItem's UserCmdID parameter.
 

See Also

Availability

DraftSight V1R1