2

TAction のリストを含む TActionClientItem のドロップダウン メニューを作成します。メニューまたは内部の各 TAction の描画イベントをフックして、これらの TAction のキャプションを別の方法で表示する方法を知りたいです!? TAction.OnDrawItem や TActionClientItem.OnDrawItem のようなもの...

procedure xxxxx.BuildActionMenu;
var
  iLoop : Integer;
  oItem : TAction;
  oClientItem : TActionClientItem;
begin
  if Assigned(oClientItem) then
    for iLoop := oClientItem.Items.Count - 1 downto 0 do
      oClientItem.Items.Delete(iLoop);

  for iLoop := 0 to List.Count - 1 do
  begin
    oItem := TAction.Create(actionList);
    oItem.Caption := List[iLoop].Name;
    oItem.Tag := iLoop;
    oItem.OnExecute := HandleOnExecuteMenuItem;
    **oItem.OnDraw = WhateverFunction**
    oClientItem .Items.Add.Action := oItem;
  end;

  if Assigned(oClientItem) then
  begin
    if oClientItem.CommandProperties is TButtonProperties then
      TButtonProperties(oClientItem.CommandProperties).ButtonType := btSplit;
    TAction(oClientItem.Action).OnExecute := HandleOnExecuteParentItem;
    **oClientItem.OnDraw = WhateverFunction**        
  end;
end;

乾杯。

4

1 に答える 1

0

カスタム描画イベント ハンドラーは、アクションではなく、常に UI コンポーネントに関連付けられます。したがって、プレーンな VCL では、要求したことを実行できません。

OnDraw イベントを追加した独自のアクション クラスを派生させるのは簡単です。接続のもう一方の端を提供するには、独自のドロップダウン メニュー クラスを派生させる必要もあります。

于 2012-02-24T07:42:54.747 に答える