Solved

Detection of Windows Start bar

Posted on 2004-03-26
5
264 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

685 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