Solved

Making a form "fsStayOnTop"

Posted on 1998-06-24
14
863 Views
Last Modified: 2008-02-01
Forms with the formstyle property set to fsStayOnTop only stay on top when they are the MainForm.

How do you make a non MainForm stay on Top?

(Delphi 3)
0
Comment
Question by:greenrc
  • 5
  • 2
  • 2
  • +5
14 Comments
 
LVL 5

Expert Comment

by:inter
ID: 1355575
Hi,
Please explain the case more. I just make a test, set form2 stay on top while form1 is the main form and form2 stays on top of form1. Do you want your any form to stay on top of other applications?
Igor
0
 

Author Comment

by:greenrc
ID: 1355576
Igor,

Form1 is the mainform.
When form1 is hidden and form2 shown, form2 does not remain on top of other applications, regardless of the formstyle being set to fsStayOnTop.


0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1355577
Hi greenrc,

 Does this work? I've got it from somewhere but I don't know anymore from where...

 Form2.SetWindowPos(Handle,
                    HWND_TOPMOST,
                    Left,
                    Top,
                    Width,
                    Height,
                    SWP_NOACTIVATE or SWP_NOMOVE or SWP_NOSIZE);

 Try to put it in some events, like OnShow, ...

Zif.
0
 

Author Comment

by:greenrc
ID: 1355578
Delphi 3 - Forms do not have a method 'SetWindowPos'
0
 
LVL 4

Expert Comment

by:BoRiS
ID: 1355579
greenrc

SetWindowPos is an API call, I think Zif meant pass it like so...

procedure TForm1.FormShow(Sender: TObject);
begin
 SetWindowPos(Handle,
                          HWND_TOPMOST,
                          Left,
                          Top,
                          Width,
                          Height,
                          SWP_NOACTIVATE or SWP_NOMOVE or SWP_NOSIZE);
end;

anyway try this and see if it works...(above)

Later
BoRiS
0
 

Author Comment

by:greenrc
ID: 1355580
Still does not remain on top of other applications....


0
 

Author Comment

by:greenrc
ID: 1355581
Adjusted points to 200
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 5

Expert Comment

by:ronit051397
ID: 1355582
try SetForegroundWindow or  BringWindowToTop
0
 

Author Comment

by:greenrc
ID: 1355583
Does not work for forms that are not the main form.
0
 
LVL 4

Expert Comment

by:d003303
ID: 1355584
..seems to be a bug in the forms unit.

Slash/d003303
0
 
LVL 2

Accepted Solution

by:
333 earned 200 total points
ID: 1355585
{It is working in Delphi2}

procedure TForm1.Button1Click(Sender: TObject);
begin
{at design time set Form2.FormStyle to fsNormal}  
  form2.show;
  form2.formstyle:=fsStayOnTop;
end;

{Form2 onDeactivate event}
procedure TForm2.FormDeactivate(Sender: TObject);
begin
 BringWindowToTop(Handle);
end;
0
 

Expert Comment

by:bome
ID: 1355586
I don't think that it is a real bug - or an intended bug. I always use fsStayOnTop for secondary windows and want that they only stay on top of my main window - not on top of all other windows on the desktop.
Imagine floating toolbars, etc. They always have this behavior.

bome

PS: d003303, you ruined me by giving me the hint to check out experts exchange... I'm hooked ! (I'm the guy in France who extended your drop wrapper)

0
 
LVL 4

Expert Comment

by:d003303
ID: 1355587
Yo bome,
nice place here, isn't it ;-)
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1355588
heck, heck, dear bome. I guess everybody here is hooked... we can't stop looking at E-E everyday. Zif. ;-)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now