Visit our Sponsor   Visit our Sponsor
delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback





Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi







Startblatt.de






Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (0)


Adding new Standard ActionsFormat this article printer-friendly!Bookmark function is only available for registered users!
Product:
Delphi 4.x (or higher)
Category:
Open Tools
API / IDE
Skill Level:
Scoring:
Last Update:
09/16/2003
Search Keys:
delphi delphi3000 article borland vcl code-snippet RegisterActions TAction TBasicAction ExecuteTarget UpdateTarget HandlesTarget
Times Scored:
3
Visits:
3512
Uploader: Andreas Schmidt
Company:
Reference: N/A
 
Question/Problem/Abstract:
how to make your own standard actions
Answer:



You can register your own new action classes with
RegisterActions.

Here is a usefull example of a action printing the current form:
Don't forget to add this unit to a design time package.



unit AjsStdActions;

interface

uses
windows, StdActns, classes, forms;


type
  
TWindowPrint = class(TWindowAction)
  public
    constructor
Create(AOwner: TComponent); override;
    procedure ExecuteTarget(Target: TObject); override;

    function HandlesTarget(Target: TObject): Boolean;override;
    procedure UpdateTarget(Target: TObject); override;

  end;

procedure Register;


implementation

uses
ActnList, Dialogs, Menus;

{ TWindowPrint }

constructor TWindowPrint.Create(AOwner: TComponent);
begin
  inherited
;
  
// new default Shortcut
  ShortCut := TextToShortCut('F3');
  
// new default Caption
  Caption  := 'Print Window';
end;

procedure TWindowPrint.ExecuteTarget(Target: TObject);
begin
  
// only for testing
   ShowMessage('Printing Windows....');
  
// print the current form
   GetForm(Target).Print;
end;


function TWindowPrint.HandlesTarget(Target: TObject): Boolean;
begin
  
Result := ((Form <> nil) and (Target = Form) or
    
(Form = nil) and (Target is TForm));
end;


procedure TWindowPrint.UpdateTarget(Target: TObject);
begin
  
// override the behavior of TWindow.UpdateTarget
end;



procedure Register;
begin
  
// register our new action class
   RegisterActions('window', [TWindowPrint], nil);
end;


end.







Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment













 
Sign up to consume product discounts for Bronze memberships !

read more


  Visit our Sponsor

 

  Community Ad of
M. Shkolnik
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)