Solved

Making a form "fsStayOnTop"

Posted on 1998-06-24
14
868 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

914 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

21 Experts available now in Live!

Get 1:1 Help Now