跳轉到主要內容
此方法用於註冊使用者自訂命令。之後可將該命令新增至工具列,或使用 ICommands::DoCommand 方法執行。

語法

C++

HRESULT RegisterUserCommand(
  MenuItemEnum CommandId,
  BSTR         CommandText,
  BSTR         IconPath,
  int          HotKey
);

C#

void RegisterUserCommand(
  MenuItemEnum CommandId,
  string       CommandText,
  string       IconPath,
  int          HotKey
);

Visual Basic .NET

Sub RegisterUserCommand( _
  CommandId As MenuItemEnum, _
  CommandText As String, _
  IconPath As String, _
  HotKey As Integer _
)

參數

CommandId [in] 指定指派給使用者命令的 ID,為 MenuItemEnum 常數。可為 MI_CustomCommand1、…、MI_CustomCommand10。 CommandText [in] 指定使用者命令的文字。 IconPath [in] 指定包含 16х16 BMP 圖片的檔案路徑,該圖片將作為命令的圖示使用。 HotKey [in] 指定命令的快速鍵。此參數的格式與傳送 Windows SendMessage 函式之 HKM_GETHOTKEY 訊息時所傳回的值 (LRESULT) 格式相同。若要取得此格式的快速鍵值,應將快速鍵的虛擬按鍵碼封裝到該值的低位元組中,並將用來指定快速鍵組合的按鍵修飾詞封裝到高位元組中。若不需要為命令使用快速鍵,請將 0 傳遞給此參數。若另一個命令已使用此快速鍵,則會傳回錯誤。您可以使用 ICommands::HasHotKey 方法檢查快速鍵是否可用。

回傳值

此方法沒有特定的回傳值。會回傳 ABBYY FineReader Engine 函式的標準回傳值

另請參閱

Commands UnregisterUserCommand MenuItemEnum