Solved

Use programming method create actionmanager item

Posted on 2004-04-26
5
324 Views
Last Modified: 2010-04-05
Dear experts,

   I have a question about actionmanager. I want to use programming method the create actionmanager->action bar-> item. Is it possible to do it? If you can, would you give me a sample for it. Thanks alot.

Tommy
0
Comment
Question by:tommyliu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 3

Expert Comment

by:MikProg
ID: 10925497
Here it is. It is smple. Add ActionBars,  ActionItems and never forget to RecreateControls to update ToolBar image.

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    ActionManager1: TActionManager;
    ActionToolBar1: TActionToolBar;
    procedure FormCreate(Sender: TObject);
    procedure YouActionExecCodeprocedure (Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  with ActionManager1.ActionBars.Add do
  begin
    ActionBar:=ActionToolBar1;
    with Items.Add do
    begin
     Action:=TAction.Create(ActionManager1);
     with Action do
     begin
       Caption:='Get It!';
       Visible:=True;
       OnExecute:=YouActionExecCodeprocedure;
     end;
    end;
  end;
  ActionToolBar1.RecreateControls;
end;

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

end.
0
 
LVL 1

Author Comment

by:tommyliu
ID: 10925680
Dear MikProg,
   I think you answer is very near, but could you give me more hints because I am a newbie. Actually I want to create a ActionMainMenuBar. Thanks for you help !

Tommy
0
 
LVL 3

Expert Comment

by:MikProg
ID: 10925820
Replace ActionToolBar1 with ActionMainMenuBar1 ... voila! you have menu with absolutely same stuff.
0
 
LVL 1

Author Comment

by:tommyliu
ID: 10925935
Dear MikProg,
   I cannot show any menu item could you help me more ???

thanks

Tommy
0
 
LVL 3

Accepted Solution

by:
MikProg earned 125 total points
ID: 10926640
 Create new project
First
  Add ActionMainMenu1 and ActionManager1 to your form
Second
  Set ActionMainMenu1.ActionManager property to ActionManager1.
Third
  Replace ALL unit text with my piece of code
Fourth
  Set Form1.OnCreate property to my FormCreate procedure.
If you want insert some code to call into YouActionExecCodeprocedure (For example Close; closes form and exits app).

Run it. You can see MenuItem 'GetIt' press it. Place break points anywhere and explore variables
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question