System Delphi

The following form shows how to add your own menu items to the form's
system menu and where to process them:

unit Unit1;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics,
Controls, Forms, Dialogs, Menus;
type
TForm1 = class (TForm)
procedure FormCreate (Sender: TObject);
private
{ private declarations }
public
procedure WinMsg (var Msg: TMsg; var Handled: Boolean);
{ This is what handles the messages }
procedure DOWHATEVER;
{ procedure to do whatever }
end;
var
Form1 : TForm1;
implementation
{$R *.DFM}
const
ItemId = 99;
{the ID number for your menu item--can be anything}
procedure TForm1.WinMsg (var Msg: TMsg; var Handled: Boolean);
begin
if Msg.message = WM_SYSCOMMAND then
{if the message is a system one...}
if Msg.WPARAM = ItemId then
DOWHATEVER
{then check if its parameter is your Menu items ID}
end;
procedure TForm1.FormCreate (Sender: TObject);
begin
Application.OnMessage := WinMsg;
{tell your app that 'winmsg' is the application message handler}
AppendMenu (GetSystemMenu (Form1.Handle, False),
MF_SEPARATOR, 0, '');
{Add a seperator bar to form1}
AppendMenu (GetSystemMenu (Form1.Handle, False),
MF_BYPOSITION, ItemId, '&New Item');
{add your menu item to form1}
AppendMenu (GetSystemMenu (Application.Handle, False),
MF_SEPARATOR, 0, '');
{Add a seperator bar to the application system menu(used }
{when app is minimized)}
AppendMenu (GetSystemMenu (Application.Handle, False),
MF_BYPOSITION, ItemId, '&New Item')
{add your menu itemto the application system menu(used when app is minimized)}

{ for more information on the AppendMenu and GetSystemMenu see online help}
end;
procedure TForm2.DOWHATEVER;
begin
{ add whatever you want to this procedure }
end;
end.