How Do I Get the Usable Coordinates of the Screen in Delphi
-
With Screen.DesktopHeight and Screen.DesktopWidth, I can get the size of the "virtual" desktop and I believe that works for one or multiple monitors. I save the position (top and left) and size (height and width) of my application into the registry when it closes. When it opens, I want to ensure it is entirely visible, since it may have been moved partly outside the visible area, or the screen size may have changed for example via screen settings or removal of a monitor. I can basically do it with this code: if MyForm.Width > screen.DesktopWidth then MyForm.Width := screen.DesktopWidth; if MyForm.Height > screen.DesktopHeight then MyForm.Height := screen.DesktopHeight; if (MyForm.Left + MyForm.Width) > screen.DesktopWidth then MyForm.Left := screen.DesktopWidth - MyForm.Width; if MyForm.Left < 0 then MyForm.Left := 0; if (MyForm.Top + LogoAppForm.Height) > screen.DesktopHeight then MyForm.Top := screen.DesktopHeight - LogoAppForm.Height; if MyForm.Top < 0 then MyFormTop := 0; This works okay, except it does not take into account the taskbar that is usually (but not always) at the bottom of the desktop. So if the taskbar is in the way of my application's window, my application gets obscured. How can I get the usable position and size settings of the screen that exclude the location of the taskbar?
-
Answer:
I'm not sure that Windows really works the way you think it does - I have multiple monitors, but they don't have the same height - so my desktop doesn't have a uniform height across all monitors. What I do is to use Screen.MonitorCount and the Screen.Monitors array to work out which monitor contains most of the window and then find a suitable rectangle on that screen. The WorkareaRect property of TMonitor gives you the bounds of the working area on a particular monitor, which excludes any taskbars or toolbars.
lkessler at Stack Overflow Visit the source
Other answers
You should use Screen.WorkArea* properties: Screen.WorkAreaRect Screen.WorkAreaHeight Screen.WorkAreaLeft Screen.WorkAreaTop Screen.WorkAreaWidth or Screen.Monitors[I].WorkareaRect
Cesar Romero
To determine the work area for the current form, use Monitor.WorkareaRect. e.g. BoundsRect := Monitor.WorkareaRect; to set the form size to the maximum area without maximising it. You should also look at the http://docs.embarcadero.com/products/rad%5Fstudio/radstudio2007/RS2007%5Fhelpupdates/HUpdate4/EN/html/delphivclwin32/Forms%5FTCustomForm%5FMakeFullyVisible.html method. From D2006 help: "MakeFullyVisible checks whether the form fits entirely on the specified monitor. If not, it repositions the form so that it fits, if possible."
Gerry Coll
Related Q & A:
- How do I get a new screen name for yahoo messenger?Best solution by sg.answers.yahoo.com
- How do I get the buddy list on my screen?Best solution by Yahoo! Answers
- How do I get my own screen name changed back to what it originally was?
- How can I get light scratches off my iPod screen?Best solution by Yahoo! Answers
- How do i get rid of lines on my screen?Best solution by ChaCha
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.