// Hiermit kann dem System-Menü der Form ein Item hinzugefügt werden.


// Getestet mit D4 unter XP

    ... 
    procedure FormCreate(Sender: TObject); 
  private 
    { Private-Deklarationen } 
  public 
    procedure AppMessage(var Msg: TMsg; var Handled: Boolean); 
    procedure machwas; 
  end; 
 
var 
  Form1: TForm1; 
 
implementation 
 
{$R *.DFM} 
 
const 
  WM_NewMenuItem = WM_USER + $FF; 
 
procedure TForm1.FormCreate(Sender: TObject); 
begin 
  Application.OnMessage := AppMessage; 
  AppendMenu(GetSystemMenu(Handle, false), MF_SEPARATOR, 0, ''); 
  AppendMenu(GetSystemMenu(Handle, false), MF_STRING, WM_NewMenuItem, 
    'Neues Menu Item'); 
end; 
 
procedure TForm1.AppMessage(var Msg: TMsg; var Handled: Boolean); 
begin 
  if (Msg.message = WM_SYSCOMMAND) and (Msg.WParam = WM_NewMenuItem) then 
  begin 
    machwas; 
    Handled := True; 
  end; 
end; 
 
procedure TForm1.machwas; // z.B. 
var x, y: integer; 
begin 
  HorzScrollbar.visible := false;           
  VertScrollbar.visible := false; 
  repeat 
    left := left + 3; 
    top := top + 2; 
    x := width; 
    y := height; 
    width := width - 6; 
    height := height - 4; 
  until (x = width) or (y = height); 
  close; 
end;



 

Zugriffe seit 6.9.2001 auf Delphi-Ecke