Solved

Detection of Windows Start bar

Posted on 2004-03-26
5
265 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

737 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