What I normally do is set the form's focus to true and/or Activate
the form I wish to have focus, in the closing form's OnClose method.  And
the way I handle this so there is no flicker or other anomalies is to first
hide the form I intend to close in whatever method event is used to initiate
its closure, then in the closing form's OnClose method I bring the form I
want to have focus to the top of the z-order, set its focus, set the closing
form to nil, and then free the closing form.

from Robert Meek dba Tangentals Design  CCopyright 2006
Proud to be a moderator of "The Delphi Lists" at elists.org

"When I examine myself and my methods of thought, I come to the conclusion
that the gift of Fantasy has meant more to me then my talent for absorbing
positive knowledge!"
                                                    Albert Einstein


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Krasimir Ivanov
Sent: Friday, July 28, 2006 4:46 AM
To: [email protected]
Subject: Little more about windows and forms

In one project I need to have more dialog forms that are dinamicaly  
created (and destroyed) and these forms are not modal. Well, suppose I  
have 3-4 formg open and I close one of them. Form is destroyed and focus  
goes to... main form. And this is not exactly what my client will need :)  
. So the
question Is how to make so, that after closing one of these forms, the  
focus goes automaticaly to last opened form?
I have some solution but need some other point of view and may be my  
solution is wrong. Here is what I made:
   for i := 1 to Screen.FormCount - 1 do
   begin
     if (Screen.Forms[i] <> Self) and (Screen.Forms[i].Parent <> Self) and
       Screen.Forms[i].Visible and Screen.Forms[i].Enabled then
     begin
       Screen.Forms[i].SetFocus;
       HaveActiveWnd := True;
       Break;
     end;
   end;

Is it ok?
-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to