T
T
TotTip2021-04-14 22:28:36
Delphi
TotTip, 2021-04-14 22:28:36

How to stretch a form across multiple monitors?

Hello!
How to stretch a form across multiple monitors?
Now I'm stretching it to full screen like this:

Form2.Width := Screen.DesktopWidth;
Form2.Height := Screen.DesktopHeight;

But the form only stretches on the active monitor.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sumor, 2021-04-14
@TotTip

Try also setting Left and Top

Form2.Left := Screen.DesktopLeft;
Form2.Top := Screen.DesktopTop;

A
acwartz, 2021-04-15
@acwartz

The Vcl.Forms module has a TScreen class through which you can enumerate monitors and get their properties.
The class does not need to be created, it is already created in the global variable Screen
Like this:

i, TotalWidth , TotalHeight : Integer;
for i = 0 to Screen.MonitorCount -1 do
begin
  TotalWidth := TotalWidth + Screen.Monitors[i].Width;
  TotalHeight := TotalHeight + Screen.Monitors[i].Heigth;
end;
 Form.Width := TotalWidth;
 Form.Heigth := TotalHeight ;

wrote the code on the knee.

H
Hemul GM, 2021-04-15
@HemulGM

The problem is different. Screen.DesktopWidth specifies the full size of the entire desktop (it's the sum of all monitors). And I checked, the window is stretched to both monitors. Look at the form settings: WindowState

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question