Link to home
Start Free TrialLog in
Avatar of xtremecris
xtremecris

asked on

Application as a toolbar

I want to make an app will will stay 'ontop' and in the upper part of the screen but all windows, even maximized, should not ocupy the surface of my application.

Something like the Office Toolbar.
Avatar of xtremecris
xtremecris

ASKER

I can make the OnTop with FormStyle, I can position the app in the upper part of the screen. But I can't figure out how to make windows not use the surface of my application(as if the desktop surface would be smaller, Office Toolbar does this).
Hi,

Try this:

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  rectOri: TRect;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
var
  rect: TRect;
begin
  Left := Screen.DesktopLeft;
  Top := Screen.DesktopTop;
  Width := Screen.DesktopWidth;
  Height := 50; // your form height here

  FormStyle := fsStayOnTop;

  // Get the current available work area
  SystemParametersInfo(SPI_GETWORKAREA, 0, @rectOri, 0);

  // Subtract the rect
  SubtractRect(rect, rectOri, Classes.Rect(Left, Top, Width, Height));

  // Set this to be the new available work area
  SystemParametersInfo(SPI_SETWORKAREA, 0, @rect, 0);
end;

procedure TForm1.FormDestroy(Sender: TObject);
var
  rect: TRect;
begin
  // restore rectOri
  SystemParametersInfo(SPI_SETWORKAREA, 0, @rectOri, 0);
end;

Regards, Geo
I would suggest creating your app as an appbar... see here for code sample: http://www.delphipages.com/tips/thread.cfm?ID=167
ASKER CERTIFIED SOLUTION
Avatar of Member_2_248744
Member_2_248744
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial