Einzelnen Beitrag anzeigen

Thomas Feichtner

Registriert seit: 30. Nov 2007
Ort: Rum
137 Beiträge
 
Delphi 10.4 Sydney
 
#8

AW: Doppelclick bei Actions verhindern

  Alt 5. Okt 2015, 08:09
Hallo!

Ich hätte mal folgendes probiert:
Eine Ableitung der ActionList und mich reingehängt.
Das funktioniert aber nur so lange in einem OnExecute nicht wieder eine andere Action aufgerufen wird.


Delphi-Quellcode:
unit myActionList;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ActnList, IniFiles, Stdctrls, Menus;

type
  TmyActionList = class(TActionList)
  private
    { Private-Deklarationen }
    oAction: TCustomAction;
    FOnExecuteAction: TNotifyEvent;
    procedure OnActionExecute(Sender: TObject);
  protected
    { Protected-Deklarationen }
  public
    { Public-Deklarationen }
    constructor Create(AOwner: TComponent); override;
    function ExecuteAction(Action: TBasicAction): Boolean; override;
  published
    { Published-Deklarationen }
  end;

var
  oCallBackToMemLog : TCallBackEventToMemLog;

implementation

constructor TmyActionList.Create(AOwner: TComponent);
begin
  inherited;
  oAction := nil;
end;

function TmyActionList.ExecuteAction(Action: TBasicAction): Boolean;
begin
  if Action is TCustomAction then begin
    FOnExecuteAction := TCustomAction(Action).OnExecute;
    TCustomAction(Action).OnExecute := OnActionExecute;
    oAction := TCustomAction(Action);
    oAction.Enabled := False;
  end;
end;

procedure TmyActionList.OnActionExecute(Sender: TObject);
begin
  if Assigned(FOnExecuteAction) then begin
    FOnExecuteAction(Self);
  end;
  oAction.Enabled := True;
  TCustomAction(oAction).OnExecute := FOnExecuteAction;
end;

end.
mfg

Thomas Feichtner
  Mit Zitat antworten Zitat