🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.pascal.delphi.misc
Article #572

Re: Always OnTop Isn't...

#572
From: Rudy Velthuis
Date: Fri, 19 Dec 1997 00:00
66 lines
2396 bytes

David Block schrieb in Nachricht
<349899d4.44687912@news.nothingbutnet.net>...
>On Sun, 14 Dec 1997 23:02:50 +0200, Krasimir Stoyanov
><krasi@internet-bg.bg> wrote:
>
>>Hello,
>>I don't know why but when you hide the main form from FormShow of
Form2 the
>>problem does not appear.
>>The following works:
>>
>>  try
>>    Form2 := TForm2.Create(Self);
>>    //Hide;       { Hide main form in FormShow of Form2 }
>>    Form2.ShowModal;
>>    Show;
>>  finally
>>    Form2.Free;
>>    Form2 := nil;
>>  end;
>>
>>********** end of code
>>and
>>********** Form2 OnShow event handler
>>procedure TForm2.FormShow(Sender: TObject);
>>begin
>>  form1.hide;
>>  SetWindowPos(Handle, HWND_TOPMOST,
>>      0,0,0,0,
>>      SWP_NOACTIVATE+SWP_NOMOVE+SWP_NOSIZE);
>>end;
>>
>>Regards,
>>Krasimir Stoyanov
>>


How about this. I added another button on Form1 (Button2) and used
Application.NormalizeTopMosts and Application.RestoreTopMosts. I
suppose these two procedures are called somewhere in the
hiding/showing mechanism of Delphi 3.

My added OnClick handler:

// I added Button2 to try this.
// Form2 has a FormStyle of fsStayOnTop now
procedure TForm1.Button2Click(Sender: TObject);
begin
  try
    Form2 := TForm2.Create(Self);
    Hide;
    Application.NormalizeTopMosts;
    Form2.ShowModal;
    Application.RestoreTopMosts;
    Show;
  finally
    Form2.Free;
    Form2 := nil;
  end;
end;

Now it works. I don't exactly know why, however.

Rudy Velthuis.
Technical Details
Message-ID: <67do9u$75e$8@demdwu11.telemedia.de>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <348f1cfa.28270490@news.nothingbutnet.net> <3494497A.522EA301@internet-bg.bg> <349899d4.44687912@news.nothingbutnet.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 104e31,23a5bae567bd42b1
X-Google-Attributes: gid104e31,public
X-Google-Thread: 1091e5,23a5bae567bd42b1
X-Google-Attributes: gid1091e5,public
X-Google-Thread: 10baee,23a5bae567bd42b1
X-Google-Attributes: gid10baee,public
From: "Rudy Velthuis" <rvelthuis@cww.de>
Subject: Re: Always OnTop Isn't...
Date: 1997/12/19
Message-ID: <67do9u$75e$8@demdwu11.telemedia.de>
X-Deja-AN: 308556761
Content-Transfer-Encoding: 7bit
References: <348f1cfa.28270490@news.nothingbutnet.net> <3494497A.522EA301@internet-bg.bg> <349899d4.44687912@news.nothingbutnet.net>
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3
Organization: Telemedia News Server
Newsgroups: comp.lang.pascal.delphi.misc,comp.lang.pascal.delphi,borland.public.delphi.winapi