Command 元素

表示命令定義。

使用方式

<Command
  Name = "xs:string"
  Symbol = "xs:string"
  Id = "xs:positiveInteger union xs:string"
  Comment = "xs:string"
  LabelTitle = "xs:string"
  LabelDescription = "xs:string"
  TooltipTitle = "xs:string"
  TooltipDescription = "xs:string"
  Keytip = "xs:string">
  child elements
</Command>

屬性

屬性 類型 必要 描述
註解
xs:string

用來標注命令元素。

(xs:string)
由任何字元序列組成的字串,包括空白字元和分行符號。
最大長度:250 個字元。
Id
xs:positiveInteger union xs:string

唯一的資源識別碼。

(xs:positiveInteger 和 xs:string) 的聯集
介於 2 到 59999 之間的整數值,包含或0x2,且包含十六進位且包含0xea5f。
最大長度為 10 個字元,包括選擇性前置零。
Keytip
xs:string

字串,表示命令專案的鍵盤快速鍵。

(xs:string)
由任何字元序列組成的字串,包括空白字元。
LabelDescription
xs:string

字串,表示顯示在命令專案上的文字。

(xs:string)
由任何字元序列組成的字串,包括空白字元和分行符號。
LabelTitle
xs:string

字串,表示顯示在命令專案上的文字。

(xs:string)
由任何字元序列組成的字串,包括空白字元和分行符號。
名稱
xs:string

(xs:string)
由字母或底線所組成的字串,後面接著任何數位序列、字母或底線。
最大長度:100 個字元。
符號
xs:string

(xs:string)
由字母或底線所組成的字串,後面接著任何數位序列、字母或底線。
最大長度:100 個字元。
TooltipDescription
xs:string

字串,表示顯示在命令專案上的文字。

(xs:string)
由任何字元序列組成的字串,包括空白字元和分行符號。
TooltipTitle
xs:string

字串,表示顯示在命令專案上的文字。

(xs:string)
由任何字元序列組成的字串,包括空白字元和分行符號。

子元素

元素 描述
Command.Comment
最多可能發生一次

Command.Id
最多可能發生一次

Command.Keytip
最多可能發生一次

Command.LabelDescription
最多可能發生一次

Command.LabelTitle
最多可能發生一次

Command.LargeHighContrastImages
最多可能發生一次

Command.LargeImages
最多可能發生一次

Command.Name
最多可能發生一次

Command.SmallHighContrastImages
最多可能發生一次

Command.SmallImages
最多可能發生一次

Command.Symbol
最多可能發生一次

Command.TooltipDescription
最多可能發生一次

Command.TooltipTitle
最多可能發生一次

父元素

元素
Application.Commands

備註

必要。

每個 Application.Commands 元素可能會發生一或多次。

Command元素的子項目可能會依任何順序發生。

一般而言,命令資源會在功能區標記中宣告,但也可以在執行時間使用 SetUICommandProperty 呼叫來設定。 例如,您可以設定 Command 的 UI_PKEY_Keytip 屬性,而不是使用 Command.Keytip 元素在標記中宣告值。

如果命令屬性,例如標籤和影像,無法使用 SetUICommandProperty 來設定,它們可能會因為呼叫 InvalidateUICommand而失效。 無效之後,架構會查詢主應用程式以取得資源詳細資料。

注意

資源在標記資源資料表失效之後無法從該資源資料表中恢復。

命令定義會針對標記中宣告的每個 命令 ,新增至功能區標記標頭檔。

除非透過功能表項目公開該 Command, 否則 Keytip 的值會做為命令的鍵盤快速鍵。 在此情況下,架構會忽略 Keytip 值,並改用以 LabelTitleUI_PKEY_Label所指定之 ampers 和 之前的字元。 如果未由 LabelTitle 或UI_PKEY_Label指定 ampersand,則不會公開按鍵或鍵盤快速鍵。

範例

下列範例顯示[常用] 索引標籤的Command元素資訊清單。

<Application.Commands>
<Command Name="cmdHomeTab"
         LabelTitle="Home"
         Keytip="H" />
<Command Name="cmdClipboardGroup"
         Symbol="IDR_CMD_CLIPBOARD"
         Id="10000"
         Comment="Command definition for clipboard group"
         LabelTitle="Clipboard"
         Keytip="CB" />
<Command Name="cmdCopy"
         Symbol="IDR_CMD_COPY"
         LabelTitle="Copy"
         LabelDescription="Copy"
         Keytip="C"
         TooltipTitle="Copy"
         TooltipDescription="Click to copy">
  <Command.SmallImages>
    <Image>res/copyS_16.bmp</Image>
  </Command.SmallImages>
  <Command.LargeImages>
    <Image>res/copyL_32.bmp</Image>
  </Command.LargeImages>
</Command>
<Command Name="cmdPaste"
         Symbol="IDR_CMD_PASTE" >
  <Command.LabelTitle>Paste</Command.LabelTitle>
  <Command.LabelDescription>
    <String Content="Paste contents of clipboard"
            Id="10001"
            Symbol="IDR_RES_LABELDESC_PASTE" />
  </Command.LabelDescription>
  <Command.Keytip>P</Command.Keytip>
  <Command.TooltipTitle>
    <String Content="Paste contents of clipboard"
            Id="10002"
            Symbol="IDR_RES_TOOLTIP_PASTE"/>
  </Command.TooltipTitle>
  <Command.TooltipDescription>
    <String Content="Click to paste contents of clipboard"/>
  </Command.TooltipDescription>
  <Command.SmallImages>
    <Image
      Id="10010"
      MinDPI="96"
      Symbol="IDR_RES_SMALL_IMAGE96">
      <Image.Source>res/pasteS_96bpp.bmp</Image.Source>
    </Image>
    <Image Source="res/pasteS_120bpp.bmp"
           Id="10011"
           MinDPI="120"
           Symbol="IDR_RES_SMALL_IMAGE120" />
  </Command.SmallImages>
  <Command.LargeImages>
    <Image>res/pasteL_32.bmp</Image>
  </Command.LargeImages>
</Command>
<Command Name="cmdMinimize"
         Symbol="IDR_CMD_MINIMIZE"
         Id="10001"
         LabelTitle="Minimize" />
</Application.Commands>

項目資訊

  • 最低支援的系統:Windows 7
  • 可以是空的:否