SysMenu:HMenu; WM_ABOUT=WM_USER+20; //****************************************** //add about menu item SysMenu:=GetSystemMenu(Application.Handle,False); AppendMenu(SysMenu,MF_SEPARATOR,0,nil); AppendMenu(SysMenu,MF_STRING,WM_ABOUT,pchar('About...')); SysMenu:=GetSystemMenu(Handle,False); AppendMenu(SysMenu,MF_SEPARATOR,0,nil); AppendMenu(SysMenu,MF_STRING,WM_ABOUT,pchar('About...')); Application.OnMessage:=OnAppMessage; procedure OnAppMessage(var Msg : TMsg ; Var Handled : Boolean);procedure TFormMain.OnAppMessage(var Msg : TMsg ; Var Handled : Boolean); //about menuitem in system menu //2002.09.01 begin if Msg.message=WM_SYSCOMMAND then begin if Msg.wParam=WM_ABOUT then begin try FormAbout:=TFormAbout.Create(self); FormAbout.ShowModal; finally FormAbout.Free; end; end; end; end;
procedure TForm1.FormCreate(Sender: TObject); begin AppendMenu(GetSystemMenu(Handle, False), MF_SEPARATOR, 0, ''); AppendMenu(GetSystemMenu(Handle, False), MF_STRING, 1111, '&About...'); AppendMenu(GetSystemMenu(Application.Handle, False), MF_SEPARATOR, 0, ''); AppendMenu(GetSystemMenu(Application.Handle, False), MF_STRING, 1111, '&About...'); Application.OnMessage := AppMessage; end; procedure TForm1.AppMessage(var Msg: TMsg; var Handled: Boolean); begin if (Msg.Message = WM_SYSCOMMAND) and (Msg.WParam = 1111) then begin with TFormAbout.Create(Self) do try Handled := True; ShowModal; finally Release; end; end; end;
//add about menu item
SysMenu:=GetSystemMenu(Application.Handle,False);
AppendMenu(SysMenu,MF_SEPARATOR,0,nil);
AppendMenu(SysMenu,MF_STRING,WM_ABOUT,pchar('About...'));
SysMenu:=GetSystemMenu(Handle,False);
AppendMenu(SysMenu,MF_SEPARATOR,0,nil);
AppendMenu(SysMenu,MF_STRING,WM_ABOUT,pchar('About...'));
Application.OnMessage:=OnAppMessage;
procedure OnAppMessage(var Msg : TMsg ; Var Handled : Boolean);procedure TFormMain.OnAppMessage(var Msg : TMsg ; Var Handled : Boolean);
//about menuitem in system menu
//2002.09.01
begin
if Msg.message=WM_SYSCOMMAND then begin
if Msg.wParam=WM_ABOUT then begin
try
FormAbout:=TFormAbout.Create(self);
FormAbout.ShowModal;
finally
FormAbout.Free;
end;
end;
end;
end;
begin
AppendMenu(GetSystemMenu(Handle, False), MF_SEPARATOR, 0, '');
AppendMenu(GetSystemMenu(Handle, False), MF_STRING, 1111, '&About...');
AppendMenu(GetSystemMenu(Application.Handle, False), MF_SEPARATOR, 0, '');
AppendMenu(GetSystemMenu(Application.Handle, False), MF_STRING, 1111, '&About...');
Application.OnMessage := AppMessage;
end; procedure TForm1.AppMessage(var Msg: TMsg; var Handled: Boolean);
begin
if (Msg.Message = WM_SYSCOMMAND) and (Msg.WParam = 1111) then
begin
with TFormAbout.Create(Self) do
try
Handled := True;
ShowModal;
finally
Release;
end;
end;
end;