Delphi 7中的TActionMainMenuBar主菜单项切换结尾

我在一个Delphi 7项目中使用TActionToolBar和TActionMainMenuBar。 当我浏览一个主菜单并且我想更改为另一个(4ex文件进行编辑)时,我必须在另一个菜单项上单击两次以进行更改(1.关闭第一个,第二个,打开新的子菜单菜单)。 使用TMainMenu这是无缝的,只需移动另一个菜单项即可,子菜单会自动更改。 我应该重写哪些消息,或者我应该做些什么API来实现类TMainMenu行为? 必须有一个解决方案,因为Delphi 7 IDE使用相同的组件,而且它的行为是正确的。

dclact70.bpl的日期:10.08.2002(dd.mm.yyyy)

Unit1.pas:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ActnList, XPStyleActnCtrls, ActnMan, ToolWin, ActnCtrls,
  ActnMenus;

type
  TForm1 = class(TForm)
    ActionMainMenuBar1: TActionMainMenuBar;
    ActionManager1: TActionManager;
    Action1: TAction;
    Action1_1: TAction;
    Action1_2: TAction;
    Action2: TAction;
    Action2_1: TAction;
    Action2_2: TAction;
    procedure emptyActionHandler(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.emptyActionHandler(Sender: TObject);
begin
//
end;

end.

unit1.dfm:

object Form1: TForm1
  Left = 584
  Top = 180
  Width = 870
  Height = 640
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object ActionMainMenuBar1: TActionMainMenuBar
    Left = 0
    Top = 0
    Width = 854
    Height = 29
    ActionManager = ActionManager1
    Caption = 'ActionMainMenuBar1'
    ColorMap.HighlightColor = clWhite
    ColorMap.BtnSelectedColor = clBtnFace
    ColorMap.UnusedColor = clWhite
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clMenuText
    Font.Height = -12
    Font.Name = 'Segoe UI'
    Font.Style = []
    Spacing = 0
  end
  object ActionManager1: TActionManager
    ActionBars = <
      item
        Items = <
          item
            Items = <
              item
                Action = Action1_1
                Caption = '&Action1_1'
              end
              item
                Action = Action1_2
                Caption = 'A&ction1_2'
              end>
            Action = Action1
            Caption = '&Action1'
          end
          item
            Items = <
              item
                Action = Action2_1
              end
              item
                Action = Action2_2
              end>
            Action = Action2
            Caption = 'A&ction2'
          end>
        ActionBar = ActionMainMenuBar1
      end
      item
        Items = <
          item
            Action = Action2_1
          end
          item
            Action = Action2_2
          end>
      end>
    Left = 8
    Top = 40
    StyleName = 'XP Style'
    object Action1: TAction
      Caption = 'Action1'
      OnExecute = emptyActionHandler
    end
    object Action1_1: TAction
      Category = 'ac1'
      Caption = 'Action1_1'
      OnExecute = emptyActionHandler
    end
    object Action1_2: TAction
      Category = 'ac1'
      Caption = 'Action1_2'
      OnExecute = emptyActionHandler
    end
    object Action2: TAction
      Caption = 'Action2'
      OnExecute = emptyActionHandler
    end
    object Action2_1: TAction
      Category = 'ac2'
      Caption = 'Action2_1'
      OnExecute = emptyActionHandler
    end
    object Action2_2: TAction
      Category = 'ac2'
      Caption = 'Action2_2'
      OnExecute = emptyActionHandler
    end
  end
end
链接地址: http://www.djcxy.com/p/91081.html

上一篇: The TActionMainMenuBar main menu item switch stutters in Delphi 7

下一篇: Exception loading ssleay32 with Indy10 with HTTP Server