给系统菜单添加菜单项

给系统菜单添加菜单项

本例效果图:

给系统菜单添加菜单项
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.
posted on 2008-04-28 21:43  万一  阅读(2844)  评论(3)  编辑  收藏
上一篇:本博客主题的相关配制


下一篇:2020-12-08