给系统菜单添加菜单项

本例效果图:

给系统菜单添加菜单项
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure SysMenu(var msg: TWMMenuSelect); message WM_SYSCOMMAND;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
  hm: HMENU;
begin
  hm := GetSystemMenu(Handle, False);
  AppendMenu(hm, MFT_SEPARATOR, 0, nil);
  AppendMenu(hm, MFT_STRING, 100, '新菜单项');
end;

procedure TForm1.SysMenu(var msg: TWMMenuSelect);
begin
  if msg.IDItem = 100 then
    ShowMessage('新菜单项')
  else inherited;
end;

end.

 
 
 
 
 

 

 
  

你可能感兴趣的:(给系统菜单添加菜单项)