How can I select the monitor where I want to open my application? [duplicate]
Asked Answered
M

1

7

Possible Duplicate:
Start program on a second monitor?

I have two monitor a monitor connected to my laptop. How can I choose the monitor where my application will show?

Also how can I detect how many monitor do I have connected so that I can select one ?

Thanks

Massingill answered 18/9, 2010 at 14:43 Comment(1)
Possible duplicate and related question: stackoverflow.com/questions/206400Gefell
F
7

Use the Screen object.

Getting the monitor count

ShowMessage(IntToStr(Screen.MonitorCount))

Getting monitor details

Screen.Monitors[i].Left (integer)
                  .Top (integer)
                  .Width (integer)
                  .Height (integer)
                  .BoundsRect (TRect)
                  .WorkareaRect (TRect)
                  .Primary (boolean)

where i is the index of the monitor, that is, i = 0, 1, ..., Screen.MonitorCount - 1.

So, for instance, to make the form occupy the entire ith monitor, use

BoundsRect := Screen.Monitors[i].BoundsRect; // or you could make the rect smaller
WindowState := wsMaximized; // possibly
Ferwerda answered 18/9, 2010 at 14:46 Comment(1)
Of course, for very simply situations, setting the DefaultMonitor property might be enough for ones needs.Ferwerda

© 2022 - 2024 — McMap. All rights reserved.