Henry Olive 5 Posted March 7 Good Day, Procedure TForm1.MyProc; begin .... end; TForm1..DBGrid2DblClick(Sender: TObject); begin MyProc = Nil; // i want to disable myproc procedure, how? ....... MyProc:=MyProc; // i want to enable myproc procedure, how? end; Thank You Share this post Link to post
programmerdelphi2k 197 Posted March 7 (edited) it would be this? private/public TForm1.myproc(Sender: TObject); .... form1.dbgridDblClick := nil; .... in another place form1.dbgridDblClick := myproc; Edited March 7 by programmerdelphi2k Share this post Link to post
programmerdelphi2k 197 Posted March 7 (edited) or this: type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private procedure OrThisProc(Sender: TObject); public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} type TMyProcX = procedure(Sender: TObject); var MyProcX: TMyProcX; MyProcY: TNotifyEvent; // = procedure(Sender : TObject) of object; <-- in this case, Object = Form1 procedure HelloWorld(Sender: TObject); begin end; procedure TForm1.OrThisProc(Sender: TObject); begin end; // to better understanding... it was edited: begin // when it shouldnt be used MyProcX := nil; MyProcY := nil; // when, it should be... MyProcX := HelloWorld; MyProcY := OrThisProc; // before any use, test it if Assigned(MyProcX) then MyProcX(Sender); // if Assigned(MyProcY) then MyProcY(Sender); end. Edited March 7 by programmerdelphi2k Share this post Link to post
SwiftExpat 64 Posted March 7 I think what you are looking for is this, declare a var to the type of the event. procedure TfrmRTCaddie.LicenseEditRefresh(const AValid: boolean; AInvalidReason: string); var ne: TNotifyEvent; //variable of event type begin ne := edtLicKeyCode.OnChange; //set the variable to the current onchagne edtLicKeyCode.OnChange := nil; //set on change to nil //work goes here edtLicKeyCode.OnChange := ne; //asign the event hander back to the control event end; Share this post Link to post
aehimself 342 Posted March 7 TMyForm = Class(TForm) strict private _doit: Boolean; [...] Procedure TMyForm.MyProc; Begin If Not _doit Then Exit; [...] End; TForm1..DBGrid2DblClick(Sender: TObject); Begin _doit := False; Try [...] Finally _doit := True; End; End; 1 Share this post Link to post
programmerdelphi2k 197 Posted March 7 (edited) using "conditionals" is going to make it very unsafe... any other method can undo... better "nil" ED, then nothing will happen! for sure! NOTE: OF COURSE, ,any other method can UNdo it (nil...) too... but this "way" is done by default when building your class on Delphi. Edited March 7 by programmerdelphi2k Share this post Link to post
Fr0sT.Brutal 816 Posted March 16 (edited) type TSomeProc = procedure of object; TForm private procedure DefProc; public NullableProc: TSomeProc; end Form1.NullableProc := nil; Form1.NullableProc := @DefProc; Edited March 16 by Fr0sT.Brutal Share this post Link to post