Notice Of Closure

Please note that this website is due to close down on 15th June 2020.

In the interim I will try to move as much content as possible over to my GitHub account. Thanks to everyone who has supported the site over the years.

» Help

Ensure a form stays in the background


The following code ensures that a form always stays in the background, even when it has focus. It is done by making the form a child of the Windows desktop.

First place the following method declaration in your form's protected section:

  procedure CreateParams(var Params: TCreateParams); override;</div>

and implement the method as follows:

procedure TForm.CreateParams(var Params: TCreateParams);
  inherited CreateParams(Params);
  if Assigned(Application.MainForm) then
    Params.WndParent := GetDesktopWindow;
    Params.Style := WS_CHILD;
Author: Unknown
Contributor: Riccardo Faiella (Topellina)
Added: 2012-07-06
Last updated: 2012-07-06

« Return to contents »