Solved

Detection of Windows Start bar

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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

691 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