Newsgroups : Borland : borland.public.delphi.rtl.win32 : 2005 Dec : Screen.activeForm and form on the top
| Subject: | Screen.activeForm and form on the top |
| Posted by: | "mee" (b.ebl..@magic.fr) |
| Date: | Thu, 22 Dec 2005 13:59:38 |
I'm using Delphi 2005 Pro for a Win32 project (SDI full screen application).
I have a main form and other secondary forms smaller than the main form.
I needed a system to make "darker" the main form when one or more
secondary form are displayed. So the secondary forms seems highlighted.
For that, I have a special "big" form with nothing inside. Its property
"Enabled" is set to false, it's color is black and it is AlphaBlended.
No title bar, no border
When I need to display a secondary form, I first display the
alphablended form then the secondary form. when the secondary form is
closed, I close also the alphablended form.
In fact theyre is a reference counter to display the alphablended form
when the first secondary form is displayed and to close the alphablended
form when the last secondary form is closed.
For one reason (I'm still investigating why) specialy on slow PC,
sometime the application is in a state where the alphablended form is on
the top of all windows and the application seems frozen (full screen
application, alphablended form without tile bar nor border) and the only
way is to use Ctrl-Alt-Del and kill the application.
Before founding the real cause of the problem, I need a way to quickly
solve it. For that, I have put a timer on the alphablended form and in
its ontimer event, I try to know if the form on the top is the
alphablended form. If yes, I make a loop in the Screen.forms list and
set the focus for all secondary forms.
The code looks like:
if Screen.ActiveForm = self then
begin
if Screen.FormCount > 0 then
for i := 0 to Screen.FormCount -1 do
begin
if Screen.Forms[i] is TFrmBasePopUp then
begin
Try
Screen.Forms[i].SetFocus;
except
Continue;
end;
end;
end;
end;
But it didn't work. When I have the problem, if I debug this code, the
screen.ActiveForm is not the alphablended form. Maybe because the
enabled property of the alphablended form is set tor false.
How can I detect that the alphablended form is on the top ?
Thanks.