Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make my Forms always to be on top my main form?

How to make my non-modal forms to always be on top of my main form?

I have tried:

procedure TForm3.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams(Params);
  Params.WndParent := Application.MainForm.Handle;
end;

Which seems to work fine. Is that correct way?

like image 988
Vlad Avatar asked Dec 13 '13 18:12

Vlad


People also ask

How do you make a form always on top?

You can bring a Form on top of application by simply setting the Form. topmost form property to true will force the form to the top layer of the screen, while leaving the user able to enter data in the forms below. Topmost forms are always displayed at the highest point in the z-order of the windows on the desktop.

How do I make a form always on top in VB net?

And in VB.NET, it is simple to keep a form at the top using the TopMost property of the form as True. After setting the TopMost property to true, the Uppermost form of a Windows application that overlaps all other forms, even if the Uppermost form is not in the active or foreground form.

Where does the name of the application appear in VB net?

Where did the name of the application appear in VB net? At the top of the form there is a title bar which displays the forms title. Form1 is the default name, you can change the name to your convenience . The title bar also includes the control box, which holds the minimize, maximize, and close buttons.


1 Answers

This is the Win32 concept of window ownership. An owned window always appears on top of its owner. The owner is specified in the call to CreateWindow and can then not be modified.

In the VCL you specify the owner by setting WndParent in CreateParams, and the framework then passes that on to CreateWindow. The VCL does this for you but in older versions the owner handling is, well, somewhat flaky. Modern versions are better and allow more control through the PopupMode and PopupParent properties.

Your code will therefore have the effect that you desire.

like image 97
David Heffernan Avatar answered Sep 21 '22 19:09

David Heffernan