From
http://www.xploiter.com/programming/delphi/tips5.shtml#tip43


Tip 43
How to force a window 'always on top' without interference with other
programs

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    procedure SetStayOnTop(OnTop: Boolean);
    procedure WinMsg(var Msg: TMsg; var Handled: Boolean);
  public
    property StayOnTop: boolean read FStayOnTop write SetStayOnTop;
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

const
  WM_ALWAYSONTOP = 99;

procedure TForm1.FormCreate(Sender: TObject);
begin
  inherited Create(AOwner);
  Application.OnMessage := WinMsg;
  AppendMenu(GetSystemMenu(Handle, False), MF_SEPARATOR, 0, '');
  AppendMenu(GetSystemMenu(Handle, False), MF_BYPOSITION,
WM_ALWAYSONTOP,
'Always on &Top');
end;

procedure TForm1.WinMsg (var Msg: TMsg; var Handled: Boolean);
begin
  if Msg.message = WM_SYSCOMMAND then
    if Msg.WPARAM = WM_ALWAYSONTOP then
      StayOnTop := not StayOnTop;
end;

procedure TForm1.SetStayOnTop(OnTop: Boolean);
begin
  FStayOnTop := OnTop;

  if FStayOnTop then begin
    SetWindowPos(handle, HWND_TOPMOST, Left, Top, Width, Height, 0);
    CheckMenuItem(GetSystemMenu(Handle, False), WM_ALWAYSONTOP,
MF_CHECKED);
  end
  else begin
    SetWindowPos(handle, HWND_NOTOPMOST, Left, Top, Width, Height, 0);
    CheckMenuItem(GetSystemMenu(Handle, False), WM_ALWAYSONTOP,
MF_UNCHECKED);
  end;
end;
end. 

I am sure there is a message box in Delphi that stays top but I cannot
fidit in help. i think I saw it in connection with error reporting.

Bob Pointoni




>>> [EMAIL PROTECTED] 18/05/2005 09:10:14 >>>
I have written a diary application where I can add reminders that pop
up at
pre-defined times, but I am currently just using ShowMessage. The
problem with
this is if my diary application is not the current window, then the
ShowMessage
just sits there until I return to the application.
Could anyone please tell me how I can pop up a message on top of other
Windows.

Regards,
Steve Bowker



****************************************************************
Wincanton plc is a leading European provider of supply chain solutions.
 We design, implement and operate creative solutions for customers in 15
countries.  Our business has a turnover of over EUR2.4bn /1.68bn pounds
and employs 27,000 staff across 360 locations.  Warehousing, transport
and specialist services are provided for customers in a range of sectors
including automotive, retail, FMCG, petrochemicals and manufacturing. 
Further information on our unique achievements and competencies can be
found by visiting 

www.wincanton.co.uk 
****************************************************************
This e-mail and any files transmitted with it are confidential 
and intended solely for the use of the individual(s) to whom it 
is addressed.  If you have received this e-mail in error please 
contact IT Service Desk on +44 (0) 870 870 9393 or e-mail
[EMAIL PROTECTED] 

Any views or opinions expressed are solely those of the author 
and do not necessarily represent those of Wincanton plc
or any of its subsidiary companies.  Unauthorised publication, 
use, dissemination, forwarding, printing or copying of this 
e-mail and its associated attachment(s) is strictly prohibited.
Wincanton plc, Methuen Park, Chippenham, Wiltshire SN14 0WT.
****************************************************************


_______________________________________________
Delphi mailing list -> [email protected] 
http://www.elists.org/mailman/listinfo/delphi

_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to