I had to find a fix to the Z-Order window problem when my login dialog
pop up after a user timeout. The login form was being displayed behind
the last modal dialog opened by the user, so the password field could
not be seen, unless the user hit ALT-TAB.
Here is how I solved this problem, I would like to know if its right:
1. Add a disabled timer control to the login form
2. In the OnShow of the form, enable the timer
3. In the event handler of the timer do this:
procedure Tfrmlogin.Timer1Timer(Sender: TObject);
begin
if ( Self <> nil ) then
begin
if ( GetForegroundWindow() <> Self.Handle ) then
begin
SetForegroundWindow(Self.Handle);
end;
end
else
begin
Timer1.Enabled := False;
end;
end;
--