Solved

Making a form "fsStayOnTop"

Posted on 1998-06-24
14
875 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
ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 

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
 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

777 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