Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Just call it directly passing the param :</p> <pre><code>procedure TfmAPRBasedForm.TSDragEvent(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if something then dosomething else begin TButton(Sender.OnMouseDOwn) := OMDold // OMDold in most cases returns nil (not null) but its ok I just want to clear custom event from the object //line below is a point of my question - the one I used doesnt work If Assigned(TButton(Sender).OnMouseDown) then // Check if there is really an TMouseEvent TButton(Sender).OnMouseDown(Sender,Button,Shift,X,Y) //Call only when Event exist end; end; </code></pre> <p>You may need to changed the Button, Shift, X, Y though if you are using them in your OMDOld and you need the value other then current value in the dragEvent, like removing ssShift or so.</p> <p>If your OMDold is stored as TMethod then you can use :</p> <pre><code>TMouseEvent(OMDOld)(Sender,Button,Shift,X,Y); </code></pre> <p>Below is a full test example adjusted to show what you want to achieve in similar fashion :</p> <pre><code>Unit Unit4; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm4 = class(TForm) btn1: TButton; btn2: TButton; procedure FormCreate(Sender: TObject); procedure btn1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure btn2MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); private { Private declarations } procedure NewMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); public { Public declarations } OMDold : TMouseEvent; IsNew : Boolean; end; var Form4: TForm4; implementation {$R *.dfm} procedure TForm4.FormCreate(Sender: TObject); begin OMDold := btn1.OnMouseDown; btn1.OnMouseDown := NewMouseDown; IsNew := True; end; procedure TForm4.NewMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if IsNew then ShowMessage('New Method!') else if Assigned(OMDold) then OMDold(Sender,Button,Shift,X,Y); end; procedure TForm4.btn1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin ShowMessage('Original Method!'); end; procedure TForm4.btn2MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin IsNew := not IsNew; end; end. </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload