Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2005 Oct : OnDeactivate endless loop

www.cryer.info
Managed Newsgroup Archive

OnDeactivate endless loop

Subject:OnDeactivate endless loop
Posted by:"preston" (orac..@xmission.com)
Date:Wed, 12 Oct 2005 08:02:27 -0600

I have a program that in the Application.OnDeactivate calls a
Form.OnDeactivate. The FormDeactivate then shows a modal dialog. Once
this happens it basically creates an endless loop in which the
Application.OnDeactivate is called over and over again, thereby calling
the modal dialog over and over agin..

Can someone explain what is going on? I know I can code around it, I'd
just like to understand this better. I'm sure it has something to do
with how Windows deals with the WMessages.

Preston


unit Unit1;

interface

uses
   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

type
   TForm1 = class(TForm)
     procedure FormDeactivate(Sender: TObject);
     procedure FormCreate(Sender: TObject);
   private
     { Private declarations }
   public
     { Public declarations }
   end;

var
   Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormDeactivate(Sender: TObject);
begin
   ShowMessage('Deactivating');
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
   Application.OnDeactivate := FormDeactivate;
end;

end.

Glossary

File Types

Replies:

www.cryer.info
Managed Newsgroup Archive