Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Einem Event zugewiesene Ereignisprozedur ermitteln? (https://www.delphipraxis.net/147195-einem-event-zugewiesene-ereignisprozedur-ermitteln.html)

uligerhardt 3. Feb 2010 16:27

Re: Einem Event zugewiesene Ereignisprozedur ermitteln?
 
Ich hab sowas ähnliches mal in der Art gelöst:
Delphi-Quellcode:
type
  TActionType = (atFileNew, atFileOpen, ...);
  TActionTypes = set of TActionType;

  TMyActions = record
  strict private
    FActions: array[TActionType] of TAction;
  private
    function GetAction(AType: TActionType): TAction;
  public
    procedure CreateActions(ATypes: TActionTypes); // Erstellt die gewünschten Aktionen
    property Actions[AType: TActionType]: TAction read GetAction; // Falls du von außen was mit der Aktion anstellen willst.
  end;

procedure TMyActions.CreateActions(ATypes: TActionTypes);
var
  t: TActionType;
begin
  for t in ATypes do
  begin
     FActions[t] := TAction.Create(...);
     // ...
  end;
end;

function TMyActions.GetAction(AType: TActionType): TAction;
begin
  Result := FActions[AType];
end;
Jetzt nur so aus dem Kopf hingeschustert. Vielleicht kannst du dir ja was rausziehen. :-)

implementation 3. Feb 2010 16:54

Re: Einem Event zugewiesene Ereignisprozedur ermitteln?
 
Zitat:

Zitat von freejay
Natürlich könnte ich noch Konstanten für die Tags anlegen, aber das ist alles so umständlich...

Also wenn dir das schon zu umständlich ist... :shock:
Delphi-Quellcode:
const
  ACTION_CUT           = $00;
  ACTION_COPY          = $01;
  ACTION_PASTE         = $02;
  ACTION_DELETE        = $03;
  ACTION_SELECTALL     = $04;
  ACTION_FIND          = $05;
  ACTION_REPLACE       = $06;
  ACTION_TOUPPERCASE   = $07;
  ACTION_TOLOWERCASE   = $08;

...

case Item.Tag of
  ACTION_CUT:              DoSomeThing;
  ACTION_COPY:             DoSomeThingElse;
  else DoSomethingOther;
end;

mjustin 3. Feb 2010 20:19

Re: Einem Event zugewiesene Ereignisprozedur ermitteln?
 
Zitat:

Zitat von freejay
Sollte es eine einfachere Lösung geben zu einem bestehenden (Popup-) Menü Default-Funktionen hinzuzufügen bin ich ganz Ohr ;-)

TAction und TActionList gibt es schon seit Delphi 6 (oder 5?) - und läßt bei normalen Anwendungen kaum Wünsche offen - oder ist da der Haken, dass 'Default'-Funktionen damit nicht so einfach zugewiesen werden können?

Viele Grüße,

Michael


Alle Zeitangaben in WEZ +1. Es ist jetzt 04:53 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz