Board index » delphi » A Bug in Delphi 6 and FormStyle

A Bug in Delphi 6 and FormStyle

Hi.

I have posted several messages about formstyle and StayOnTop.

When I create a new project and set the formstyle to fsStayOnTop the form is
On top. It doesn't care if I
start an IE, Netscape or an other program. So it should be, I think.

But when I start a second form and this should be the StayOnTop-Form it
doesn't work.

My project is as follows:

the first Form:

    Property
        Form-Stye =  fsNormal
        BorderStyle  = bsSizable

    Event:
        OnClick:     Form2.Showmodal        << Doesn't care: showmodal or
show

the second Form:

    Property
        Form-Stye = fsStayOnTop
        BorderStyle  = bsSizable

I am using Delphi Professional 6.0 (Build 6.163) and Windows 2000
Servicepack 2 on a Athlon 1,4 GHz with 512 MB RAM.

I hope there will be a first servicepack for Delphi available which solve
this problem.

Regards,

Rainer

 

Re:A Bug in Delphi 6 and FormStyle


Hi Rainer

Quote
"Rainer Stuelp" <Rainer.Stu...@gsd-kerpen.de> wrote in message

news:3b9e2efb_1@dnews...

Quote
> But when I start a second form and this should be the StayOnTop-Form it
> doesn't work.

When VCL detects that the application will be deactivated, VCL lower
Stay-On-Top forms
except the MainForm because VCL dose not support "Owned" forms and use
Stay-OnTop
forms instead of them.

If you want suppress this VCL behavier, use code as bellow.

procedure TForm1.FormCreate(Sender: TObject);
begin
  // Install Hool
  Application.HookMainWindow(HookToKillTopmostNomalization);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  // Uninstall Hook
  Application.UnhookMainWindow(HookToKillTopmostNomalization);
end;

function TForm1.HookToKillTopmostNomalization(var Msg: TMessage): Boolean;
begin
  Result := False;

  if Msg.Msg = WM_ACTIVATEAPP then
  begin
    Msg.Result := DefWindowProc(Application.Handle,
                                Msg.Msg,
                                Msg.WParam,
                                Msg.LParam);

    // Simulate TApplication but does not call
NormalizeTopMosts/RestoreTopMosts
    if TWMActivateAPP(Msg).Active then
      PostMessage(Application.Handle, CM_ACTIVATE, 0, 0)
    else
      PostMessage(Application.Handle, CM_DEACTIVATE, 0, 0);

    Result := True;
  end;
end;

Other Threads