Solved

Use programming method create actionmanager item

Posted on 2004-04-26
5
334 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

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month2 days, 19 hours left to enroll

621 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