Link to home
Start Free TrialLog in
Avatar of Mutley2003
Mutley2003

asked on

Always on Top - even after Minimize all

Hello there

How do I make a Delphi app that will stay on top even when all apps are minimized (with the Windows+M key).

I know it is possible because dragstrip (http://www.poppybank.com/DragStrip/windows/index.htm) does it .. it keeps a little bar docked to one side of the desktop, at all times

thanks
Avatar of esoftbg
esoftbg
Flag of Bulgaria image

unit Unit2_Q_21131390;

interface

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

type
  TForm2 = class(TForm)
    Memo: TMemo;
    Timer: TTimer;
    procedure FormShow(Sender: TObject);
    procedure TimerTimer(Sender: TObject);
  private   { Private declarations }
    procedure CreateParams(var Params: TCreateParams); override;
  public    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.FormShow(Sender: TObject);
var
  B:      Boolean;
  L:      Integer;
  T:      Integer;
  R:      TRect;
begin
  B := False;
  SystemParametersInfo(SPI_GETWORKAREA, 0, @R, 0);
  T := R.Bottom - Height;
  L := R.Right - Width;
  if (T<>Top) then
  begin
    B := True;
    Top := T;
  end;
  if (L<>Left) then
  begin
    B := True;
    Left := L;
  end;
  if B then
  begin
    Memo.Clear;
    Memo.Lines.Add('Work area is the portion of the screen not obscured by the taskbar');
    Memo.Lines.Add('Left=' + IntToStr(R.Left));
    Memo.Lines.Add('Top=' + IntToStr(R.Top));
    Memo.Lines.Add('Right=' + IntToStr(R.Right));
    Memo.Lines.Add('Bottom=' + IntToStr(R.Bottom));
  end;
end;

procedure TForm2.TimerTimer(Sender: TObject);
begin
  FormShow(Self);
end;

procedure TForm2.CreateParams(var Params: TCreateParams);
begin
  inherited;
  with Params do
  begin
   ExStyle := ExStyle or WS_EX_TOPMOST;
   WndParent := GetDesktopwindow;
   Style := Style AND NOT WS_CAPTION;
 end;
end;

end.
download the full code of the above example from :
page:        http://www.geocities.com/esoftbg/
  link:        Q_21131390.zip
ASKER CERTIFIED SOLUTION
Avatar of Ivanov_G
Ivanov_G
Flag of Bulgaria 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
hello  Mutley2003, there seems to be a solution for this at the EE question - -

https://www.experts-exchange.com/questions/20340906/Catching-Windows-M.html
Avatar of fidel83
fidel83

Ivanov_G's answer works ;-)
Avatar of Mutley2003

ASKER

yes, it does, and I don't know why I did not close this off before.

My apologies, people.