Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-03

Detecting desktop area size

18 messages · 8 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bart

Hi,

Is there any (more or less) reliable way to detect the size of the desktop (that is: on the active screen, the space a form can occupy so that it will take in account the presence of a taskbar etc.)

I need something like this to keep a form that I create at runtime in view on the desktop (it's initial size and widht/height) depend on the contents it must display).

I know how to do it on Windows.
Linux (GTK2) and MAC would be nice.

Bart

Reply by email

zeljko
to Bart
Bart wrote 12 lines
Hi, Is there any (more or less) reliable way to detect the size of the desktop (that is: on the active screen, the space a form can occupy so that it will take in account the presence of a taskbar etc.) I need something like this to keep a form that I create at runtime in view on the desktop (it's initial size and widht/height) depend on the contents it must display). I know how to do it on Windows. Linux (GTK2) and MAC would be nice.

GetMonitorInfo(), GetSystemMetrics() SM_CXSCREEN,
SM_CYSCREEN,SM_CXVIRTUALSCREEN,SM_CYVIRTUALSCREEN doesn't help ?

Show quoted text 8 lines
Bart -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Paul Ishenin
to Bart: Is there any (more or less) reliable way to detect the size of the desktop (that is: on…

31.03.2011 7:06, Bart ?????:

Is there any (more or less) reliable way to detect the size of the desktop (that is: on the active screen, the space a form can occupy so that it will take in account the presence of a taskbar etc.)

..

I know how to do it on Windows. Linux (GTK2) and MAC would be nice.

TScreen.Monitors[i].WorkareaRect

Best regards,
Paul Ishenin

Reply by email

Bart
to zeljko: GetMonitorInfo(), GetSystemMetrics() SM_CXSCREEN,…
zeljko wrote
GetMonitorInfo(), GetSystemMetrics() SM_CXSCREEN, SM_CYSCREEN,SM_CXVIRTUALSCREEN,SM_CYVIRTUALSCREEN doesn't help ?

On Windows GetSystemMetrics does return the size the (virtual) desktop has, but it does not subtract the space occupied by the Windows TaskBar (see: http://msdn.microsoft.com/en-us/library/ms724385(v=vs.85).aspx). You have to use SystemparametersInfo(SPI_GETWORKAREA, 0, @WorkArea, 0 ); with WorkArea being of type TRect;

Bart

Reply by email

Sven Barth
to Bart
Bart wrote 8 lines
On 3/31/11, Paul Ishenin wrote: > TScreen.Monitors[i].WorkareaRect This seems to work for Win and Linux/GTK2. This raises yet another question though. How do I know on which monitor my form is? (I only have one monitor, so I cannot test this)

What about this:

Screen.MonitorFromWindow(YourForm.Handle);

It returns a TMonitor.

Regards,
Sven

Reply by email

Martin
to Sven Barth
Sven Barth wrote 15 lines
Am 31.03.2011 16:15, schrieb Bart: > On 3/31/11, Paul Ishenin wrote: >> TScreen.Monitors[i].WorkareaRect > > This seems to work for Win and Linux/GTK2. > > This raises yet another question though. > How do I know on which monitor my form is? > (I only have one monitor, so I cannot test this) What about this: Screen.MonitorFromWindow(YourForm.Handle); It returns a TMonitor.

Note that each monitor has it's own set of coordinates, which may be negative.

eg 2 monitor left to right may be

m1 TopRight x: -1200, y:0
m2 TopRight x: 0, y:0

Reply by email

Sven Barth
to Kjow
Kjow wrote 13 lines
2011/3/31 Sven Barth: > What about this: > > Screen.MonitorFromWindow(YourForm.Handle); > > It returns a TMonitor. > > Regards, > Sven Maybe a little OT, but is it possible to change screen resolution (e.g. on a native 19200x1200 set 800x600) in a crossplatform way? I need this for fullscreen apps (opengl in first).

I'm not really confident in this, but I believe if you tell OpenGL to be fullscreen in that or that resolution it will switch to that automatically.

Regards,
Sven

Reply by email

Reimar Grabowski
to Sven Barth: I'm not really confident in this, but I believe if you tell OpenGL to be fullscreen in…
I'm not really confident in this, but I believe if you tell OpenGL to be fullscreen in that or that resolution it will switch to that automatically.

No, it does not, because you don't give such information to OpenGL. Resolution switching or making windows fullscreen is not the task of OpenGL.

R.

A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing in e-mail?

Reply by email

Paul Ishenin
to Bart: This seems to work for Win and Linux/GTK2. This raises yet another question though. How…
Bart wrote
On 3/31/11, Paul Ishenin wrote: > TScreen.Monitors[i].WorkareaRect This seems to work for Win and Linux/GTK2.

This was tested on OSX during the development too.

This raises yet another question though. How do I know on which monitor my form is? (I only have one monitor, so I cannot test this)

Looks like search does not work on your PC anymore.

property.

Best regards,
Paul Ishenin

Reply by email

Bart
to Paul Ishenin
Paul Ishenin wrote
This was tested on OSX during the development too.

Nice.

Looks like search does not work on your PC anymore.

(Well, it is slow on my 10 year old machine, but is still works most of the time.
I also searched the forum and wiki.)

property.

Well, I did just that, but I just couldn't figure it out. I finally used something like
Screen.MonitorFromPoint(ClientToSCreen(Self.BoundsRect.TopLeft)) to get the monitor the form was currently on...

Just thougth to ask if someone had a simpler solution ;-)

Thanks to all for the help.

Bart

Reply by email

Kjow
to Hans-Peter Diettrich: Are you sure that you want to use an digital monitor (TFT...) in anything but its native…

2011/4/1 Hans-Peter Diettrich :

Show quoted text 6 lines
Are you sure that you want to use an digital monitor (TFT...) in anything but its native resolution? CRTs can be configured to a wide range of resolutions, but nowadays flatscreens, with addressable pixels, require soft-/hardware interpolation when abused for a different resolution. DoDi

Yes, some 3D apps need to make compromises to have better performances instead of best quality. :)

Kjow

Reply by email

Hans-Peter Diettrich
to Kjow: 2011/3/31 Sven Barth : Maybe a little OT, but is it possible to change screen resolution…
Maybe a little OT, but is it possible to change screen resolution (e.g. on a native 19200x1200 set 800x600) in a crossplatform way? I need this for fullscreen apps (opengl in first).

Are you sure that you want to use an digital monitor (TFT...) in anything but its native resolution? CRTs can be configured to a wide range of resolutions, but nowadays flatscreens, with addressable pixels, require soft-/hardware interpolation when abused for a different resolution.

DoDi

Reply by email

Paul Ishenin
to Hans-Peter Diettrich
Hans-Peter Diettrich wrote 9 lines
Paul Ishenin schrieb: >> How do I know on which monitor my form is? >> (I only have one monitor, so I cannot test this) > Looks like search does not work on your PC anymore. > > property. A form/window actually can span multiple monitors.

Yes, and TForm.Monitor returns one where the biggest part of the form is located.

Best regards,
Paul Ishenin

Reply by email