Mohamad
Mohamad

Reputation: 1117

prevent running main form OnActivate event

I have a simple program (in delphi 7) on its main form is a button. When I click the button on the main form, I will open the second form. When I close the second form how can I prevent running main form OnActivate event? (except this code: MainForm.OnActivate = nil)

thanks

Upvotes: 1

Views: 1108

Answers (2)

user497849
user497849

Reputation:

easiest possibility

MainForm.OnActivate := NIL;
Form2.ShowModal;
MainForm.OnActivate := MainFormOnActivate;

using something else can break future compatibility in Delphi...

Upvotes: 2

gabr
gabr

Reputation: 26830

A nice shorthand for temporarily disabling an event using GpStuff (BSD License):

uses
  GpStuff;

with DisableHandler(@@MainForm.OnActivate) do
  Form2.ShowModal;

Upvotes: 5

Related Questions