unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
const
WM_USER_INFOMENU = WM_USER + $101;
S_INFOMENU = '
&Info';
type
TForm1 =
class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
procedure OnAppMsg(
var Msg: TMsg;
var Handled: Boolean);
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.OnAppMsg(
var Msg: TMsg;
var Handled: Boolean);
begin
if (Msg.
message = WM_SYSCOMMAND)
and (Msg.wParam = WM_USER_INFOMENU)
then
begin
Application.MessageBox('
Hello World!',
nil, MB_OK
or MB_ICONINFORMATION);
Handled := True;
end else
Handled := False;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
SysMenu: HMENU;
begin
Application.OnMessage := OnAppMsg;
{Application's System Menu}
SysMenu := GetSystemMenu(Application.Handle, False);
AppendMenu(Sysmenu, MF_SEPARATOR, 0,
nil);
AppendMenu(SysMenu, MF_STRING, WM_USER_INFOMENU, S_INFOMENU);
{Form System Menu}
SysMenu := GetSystemMenu(Self.Handle, False);
AppendMenu(Sysmenu, MF_SEPARATOR, 0,
nil);
AppendMenu(SysMenu, MF_STRING, WM_USER_INFOMENU, S_INFOMENU);
end;
end.