Solved

Detection of Windows Start bar

Posted on 2004-03-26
5
262 Views
Last Modified: 2010-04-05
How can I detect if the Windows Start bar is visible or not. And how can I resize my Delphi Form to fit the screen, so that the Start bar doesn't cover the bottom of my form?

Joern
0
Comment
Question by:rainbowsoftware
  • 2
  • 2
5 Comments
 
LVL 11

Assisted Solution

by:shaneholmes
shaneholmes earned 75 total points
ID: 10687447
This was just posted by another expert


Set forms WindowsState property ro wsMaximized;

then in your onCreate event of the form, do this

Self.Width:= Screen.Width;
Self.Height:= Screen.Height;

If you dont want the border of your form, set the border style to bsNone

Shane
0
 
LVL 8

Assisted Solution

by:gmayo
gmayo earned 75 total points
ID: 10687479
Screen.WorkAreaHeight, if less than Screen.DesktopHeight, would give a rough indication of whether the taskbar is visible or not. Remember that some (weird!) people have their taskbar on the side, so you'd use the Width version instead.

Geoff M.
0
 
LVL 8

Expert Comment

by:gmayo
ID: 10687489
...which, of course, doesn't require you to set the form to maximised to test the size...
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10687499
you can use this one to get a handle to the taskbar window:

var
 dw1 : dword;

dw1 := FindWindow('Shell_TrayWnd', '');

Now call GetWindowRect to ask the position and size of the window.

Shane
0
 
LVL 17

Accepted Solution

by:
geobul earned 100 total points
ID: 10689179
Hi,

Try this:

type
  TForm1 = class(TForm)
  private
    { Private declarations }
  protected
    procedure RequestAlign; override;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

uses ShellApi;

function GetTaskBar: TAppBarData;
var
  hTaskBar: HWND;
  abd: TAppBarData;
begin
  hTaskBar := FindWindow('Shell_TrayWnd', nil);

  if (hTaskBar <> 0) then begin
    abd.cbSize := sizeof(TAppBarData);
    abd.hWnd := hTaskBar;
    SHAppBarMessage(ABM_GETTASKBARPOS, abd);
  end;

  Result := abd;
end;

procedure TForm1.RequestAlign;
var
  rect: TRect;
  abd: TAppBarData;
begin
  // Get the current available work area
  SystemParametersInfo(SPI_GETWORKAREA, 0, @rect, 0);

  // Get the task bar info (rc indicates space required even if not showing)
  abd := GetTaskBar;

  // Subtract the rect
  SubtractRect(rect, rect, abd.rc);

  // Set this to be the new available work area
  SystemParametersInfo(SPI_SETWORKAREA, 0, @rect, 0);

  inherited RequestAlign;
end;

Now all maximized apps will use the available area only. It doesn't matter if the taskbar is currently visible.

Regards, Geo
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Simple Delphi Question 9 89
LAN or WAN ? 11 90
How to convert memory stream to PDF file 6 54
Delphi Ado Query To Converts Joined Columns Into Rows Based on Primary Key 4 55
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question