Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Child form always stay above of main form

I'm using delphi 2007 and each time which I create a new form using a code like this

var
  Child : TFrmChild;
begin
  Child:=TFrmChild.Create(Self);
  Child.Show();
end;

The child form is shown and appears above all others forms , that is ok, but when a click in the main form the child form stays above of the main form. so i have two questions

  1. why the child form stay above of the main form even if a click in the main form?
  2. How i can make which the main form stay over all others forms when i click on it?

Thanks

UPDATE

this is the dfm of the child form

object FrmChild: TFrmChild
  Left = 549
  Top = 308
  Caption = 'FrmChild'
  ClientHeight = 228
  ClientWidth = 213
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
end
like image 807
DelphiNewbie Avatar asked May 09 '11 00:05

DelphiNewbie


1 Answers

You have two top level windows. The main form is the owner of the child form. Owned windows always appear above their owners, that's just one of the rules of Windows.

Note that by owner I am referring to the Windows concept rather than the Delphi concept.

The Windows Features topic explains the rules. The key statement is:

An owned window is always above its owner in the z-order.

As for how to make you app behave differently I'm not so sure. If you make your child form unowned then it will have its own taskbar button and it won't be minimised when the main form is minimised, for example.

like image 128
David Heffernan Avatar answered Oct 18 '22 03:10

David Heffernan