?
Solved

Use programming method create actionmanager item

Posted on 2004-04-26
5
Medium Priority
?
339 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 500 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

719 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