Solved

Detection of Windows Start bar

Posted on 2004-03-26
5
260 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
Comment Utility
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
Comment Utility
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
Comment Utility
...which, of course, doesn't require you to set the form to maximised to test the size...
0
 
LVL 11

Expert Comment

by:shaneholmes
Comment Utility
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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

771 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now