Recent

Author Topic: Size of screen available without taskbar ?  (Read 18259 times)

Fred vS

  • Hero Member
  • *****
  • Posts: 1675
    • miXimum is the DJ's best friend
Size of screen available without taskbar ?
« on: July 12, 2010, 02:23:59 pm »
Hello Lazarus fans.
Is it possible to know the size of the screen available without the taskbars ?
In Windows and in Linux there are taskbars (1 in bottom for Windows and 2 for Ubuntu).
I need to know the size of the screen without that taskbar(s).
Is it possible to know with Lazarus how many taskbars are installed and the height of those taskbars ?
Thanks
I use Lazarus 1.8.0 32/64 and FPC 3.0.3 32/64 on Linux Mint Mate 17 32/64, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs

eny

  • Hero Member
  • *****
  • Posts: 1588
Re: Size of screen available without taskbar ?
« Reply #1 on: July 12, 2010, 02:41:50 pm »
1 in bottom for Windows...

Never assume it's at the bottom!
There even is a bug in Lazarus that's related to this.
I always have the taskbar at the left. It's much easier to access all opened programs and the shortcuts in the quickstart menu.
All posts based on: Win10 (Win64); Lazarus 1.8.0 'stable' (#56594 win64) unless specified otherwise...

Laksen

  • Hero Member
  • *****
  • Posts: 624
    • J-Software
Re: Size of screen available without taskbar ?
« Reply #2 on: July 12, 2010, 02:47:36 pm »
Doesn't Screen.Width and screen.Height give the right information on Linux and Mac?

It gives me the full screen resolution on Windows(1680x1050)

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: Size of screen available without taskbar ?
« Reply #3 on: October 07, 2010, 02:47:30 pm »
Few months old topic, however it didn't come clear how desktop size works, or if its even possible to do these any convinient way.

My program uses this code to adjust window properly on my screen. I know it won't work for others.
What the code does is making window that is exactly from top edge to bottom - HeightOfTaskBar. On widescreen monitor i don't want to use wsMaximized, it would look stupid.
Code: [Select]
  height:=screen.Height-95;
  width:=height*4 div 3;
  top:=0; left:=(screen.Width-Width) div 2;

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1890
Re: Size of screen available without taskbar ?
« Reply #4 on: October 07, 2010, 04:24:51 pm »
or if its even possible to do these any convinient way.

I'd say no, not in a convenient way. On Linux, it depends on the Window Manager you are using.
Not even sure if X11 itself knows which window is the taskbar, probably using
"_NET_WORKAREA"

« Last Edit: October 07, 2010, 05:48:12 pm by theo »

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Size of screen available without taskbar ?
« Reply #5 on: October 07, 2010, 04:51:33 pm »
On Windows:

Code: [Select]
var
  h :THandle;
  r  :TRect;
begin
  h := FindWindow('Shell_traywnd', '');
  GetWindowRect(h, r);
end;                   

Zaher

  • Hero Member
  • *****
  • Posts: 578
    • parmaja.com
Re: Size of screen available without taskbar ?
« Reply #6 on: October 07, 2010, 06:37:23 pm »
In Windows
SPI_GETWORKAREA with SystemParametersInfo.
http://msdn.microsoft.com/en-us/library/ms724947

bonmario

  • Sr. Member
  • ****
  • Posts: 299
Re: Size of screen available without taskbar ?
« Reply #7 on: May 31, 2011, 10:56:20 am »
On Windows:

Code: [Select]
var
  h :THandle;
  r  :TRect;
begin
  h := FindWindow('Shell_traywnd', '');
  GetWindowRect(h, r);
end;                   

It works fine on Windows XP, but on Windows 7 it returns height = 40 (r.Bottom - r.Top).
I don't know which is the real height, but it's more than on Windows XP that have height = 60.

It's a bug?

Thanks, Mario

Shebuka

  • Sr. Member
  • ****
  • Posts: 422
Re: Size of screen available without taskbar ?
« Reply #8 on: May 31, 2011, 12:29:22 pm »
On Windows:

Code: [Select]
var
  h :THandle;
  r  :TRect;
begin
  h := FindWindow('Shell_traywnd', '');
  GetWindowRect(h, r);
end;                  

It works fine on Windows XP, but on Windows 7 it returns height = 40 (r.Bottom - r.Top).
I don't know which is the real height, but it's more than on Windows XP that have height = 60.

It's a bug?

Thanks, Mario

I don't know for XP but on W7 the taskbar with 'small icons' is height 30px, with normal icons 40px

from first google result

FezaCakir

  • New member
  • *
  • Posts: 7
Re: Size of screen available without taskbar ?
« Reply #9 on: February 17, 2017, 10:06:47 pm »
I think it's going to work:

Form1.Left:=Screen.WorkAreaLeft-4;
Form1.Top:=Screen.WorkAreaTop;
Form1.Width:=Screen.Width;
Form1.Height:=Screen.WorkAreaHeight-GetSystemMetrics(SM_CYCAPTION);


aurimenes

  • Newbie
  • Posts: 1
Re: Size of screen available without taskbar ?
« Reply #10 on: June 09, 2019, 10:16:50 pm »
Very very old topic - but just for future reference:

Got the answer doing this way:

Code: Pascal  [Select]
  1. procedure TfrmMenu.FormShow(Sender: TObject);
  2. begin
  3.   Left := 0;
  4.   Top := 0;
  5.   Height := screen.WorkAreaHeight;
  6.   Width := Screen.WorkAreaWidth;
  7. end;

Working fine using Win7 - tested with vertical and horizontal task bar (will test Win10 later)
Aurimenes Silva
Recife, PE - Brazil

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 680
    • Lebeau Software
Re: Size of screen available without taskbar ?
« Reply #11 on: June 11, 2019, 11:03:36 pm »
Note that SPI_GETWORKAREA/Screen.WorkArea... are for the primary monitor only.  On a multi-monitor system, each monitor has its own work area, and may or may not be displaying the taskbar.  So you have to query each monitor individually.
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

lucamar

  • Hero Member
  • *****
  • Posts: 2145
Re: Size of screen available without taskbar ?
« Reply #12 on: June 12, 2019, 12:26:51 am »
Very very old topic - but just for future reference:
[...]
Code: Pascal  [Select]
  1. procedure TfrmMenu.FormShow(Sender: TObject);
  2. begin
  3.   Left := 0;
  4.   Top := 0;
  5.   Height := screen.WorkAreaHeight;
  6.   Width := Screen.WorkAreaWidth;
  7. end;

Working fine using Win7 - tested with vertical and horizontal task bar (will test Win10 later)

For completeness sake, Screen.WorkArea rarely works in Linux. One has to use {Form.}Monitor.WorkareaRect; for example:
Code: Pascal  [Select]
  1. {Adjust form to monitor vertical space }
  2. procedure TMyForm.AdjustHeight(Breath: Integer = 0);
  3. var
  4.   MaxRect: TRect;
  5.   NewTop, NewHeight: Integer;
  6. begin
  7.   MaxRect := Monitor.WorkareaRect; {< This is the form's monitor}
  8.   NewHeight := MaxRect.Height;
  9.   if Breath > 0 then begin
  10.     NewHeight := NewHeight - Breath;
  11.     NewTop := MaxRect.Top + (MaxRect.Height - NewHeight) div 2;
  12.   end else
  13.     NewTop := MaxRect.Top;
  14.   SetBounds(Left, NewTop, Width, NewHeight);
  15. end;
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.4/2.0.6  - FPC 3.0.4 on:
(K|L)Ubuntu 12..16, Windows XP SP3, various DOSes.