Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make main form appear in 2nd monitor

Tags:

delphi

I use Delphi 10 and I have two monitors when I create default vcl application and run the application the main form always appear in the first monitor is there a way to make it appear in the second monitor by default ?

This may be option in the IDE or property or code

Thanks

like image 235
zac Avatar asked Sep 08 '25 12:09

zac


1 Answers

TForm has a DefaultMonitor property that is set to dmActiveForm by default. When no Form is active, the primary monitor is used. However, there is no way to set the DefaultMonitor to the second monitor specifically.

TForm also has a Monitor property, but for whatever reason it is read-only.

So, to display a TForm on a specific monitor, you can locate the desired monitor in the global TScreen.Monitors[] list, and then either:

  1. manually set the Form's Left/Top properties to an X/Y coordinate that is within the bounds of the monitor's BoundsRect or WorkareaRect property.

  2. pass the monitor to the Form's public MakeFullyVisible() method.

like image 119
Remy Lebeau Avatar answered Sep 10 '25 03:09

Remy Lebeau