• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1197
  • Last Modified:

Make delphi form behave lik the windows task bar

I want to make my Delphi form stay on top and visible above all other windows. Similar to the task bar. All other windows must resize to fit in with my delphi window. In other words my Delphi form is like a task bar on top of the screen and all opened windows do not cover my form.
0
mwskuzzy
Asked:
mwskuzzy
1 Solution
 
MerijnBSr. Software EngineerCommented:
What you want is called an application bar.
The API is quite complex, so I advice you to try to find something which does it for you.

Some quick finds:
http://www.delphi32.com/vcl/3688/
http://www.delphipages.com/result.cfm?ID=3120

and a commercial one I have good experiences with:
http://www.appcontrols.com/components.html
0
 
developmentguruCommented:
Check this out, it tells how to make a stay on top form and a few other goodies.

http://delphi.about.com/od/formsdialogs/l/aa073101b.htm

combine that with FormStyle := fsStayOnTop and you are most of the way there.  I will keep researching and see if I can find the answer to making other forms resize to fit around yours on the desktop.
0
 
developmentguruCommented:
You could also check out one that is a completed component that you drop on your form...

http://www.delphi32.com/vcl/2677/download,xid,2677.asp
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
developmentguruCommented:
If you really want to get into it all yourself, here is the best link I have found.

http://msdn2.microsoft.com/en-us/library/aa969323.aspx

I will work on a basic Delphi source code example.
0
 
Ralf KlattPrincipal ConsultantCommented:
Hi,

A solution to a similar question was already posted at EE:

http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_20153719.html


procedure TForm1.OnTop(SendeR: TObject);
begin
  SetWindowPos(form1.handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOACTIVATE or SWP_NOSIZE);
  SetWindowPos(form2.handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOACTIVATE or SWP_NOSIZE);
end;


Best regards,
Raisor
0
 
MerijnBSr. Software EngineerCommented:
thank you for confirming that what you need is indeed a TAppBar and that it's best to find something which does all the work for you.
0
 
mwskuzzyAuthor Commented:
Thanks for all the responses guys. I am ok with the window staying on top of the other windows. what i need is if my tool bar is open and i open another window it will maximise to the desktop area but not over my tool bar. Kind of like when you set the task bar to auto hide the desktop area increases to the bottom of your screen.

thanks
0
 
developmentguruCommented:
Here is an example that works.  It does NOT cover everything you may need.  It is still a good idea for you to check out the API.

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ShellAPI;

const
  WM_TASKBAR = WM_APP + 1;

type
  TForm1 = class(TForm)
    btnClose: TButton;
    procedure btnCloseClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    procedure CreateParams(var Params: TCreateParams); override;
    procedure TaskBarMessage(var Message: TMessage); message WM_TASKBAR;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.btnCloseClick(Sender: TObject);
begin
  Close;
end;

procedure TForm1.CreateParams
   (var Params: TCreateParams);
begin
  inherited CreateParams(Params);
  with Params do
    begin
      ExStyle := ExStyle or WS_EX_TOOLWINDOW;
      Style := Style or WS_POPUP;
    end;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
  AppBarData : TAppBarData;
  ScreenHeight : integer;

begin
  Width := Screen.Width;
  ScreenHeight := Screen.Height;

  FillChar(AppBarData, SizeOf(TAppBarData), 0);
  AppBarData.cbSize := SizeOf(TAppBarData);
  AppBarData.hWnd := Handle;
  AppBarData.uCallbackMessage := WM_TASKBAR;
  AppBarData.uEdge := ABE_TOP;
  AppBarData.rc := Rect(0, 0, Width, Height);
  //MoveWindow(Handle, 0, 0, Screen.Width, Height, true);

  shAppBarMessage(ABM_NEW, AppBarData);
  shAppBarMessage(ABM_ACTIVATE, AppBarData);
  shAppBarMessage(ABM_SETPOS, AppBarData);

  application.ProcessMessages;
end;

procedure TForm1.FormDestroy(Sender: TObject);
var
  AppBarData : TAppBarData;

begin
  //Un-Register
  FillChar(AppBarData, SizeOf(TAppBarData), 0);
  AppBarData.cbSize := SizeOf(TAppBarData);
  AppBarData.hWnd := Handle;

  shAppBarMessage(ABM_Remove, AppBarData);
end;

procedure TForm1.TaskBarMessage(var Message: TMessage);
begin
  Message.Result := 0;
end;

end.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now