Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2007 Oct : Fix to z-order window problem

www.cryer.info
Managed Newsgroup Archive

Fix to z-order window problem

Subject:Fix to z-order window problem
Posted by:"Guy Harel" (guy.har..@yahoo.com)
Date:1 Oct 2007 13:57:01 -0700

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;

--

Glossary

Replies:

www.cryer.info
Managed Newsgroup Archive