1,183
社区成员
发帖
与我相关
我的任务
分享
procedure TForm1.FormCreate(Sender: TObject);
var
FSysMenu: HMENU;
begin
FSysMenu := GetSystemMenu(Handle, False);//获得窗口系统菜单
AppendMenu(FSysMenu, MF_POPUP or MF_STRING or MF_ENABLED,
pmTitle.Handle, '标题栏测试');
end;
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus;
type
TForm1 = class(TForm)
pmScreen: TPopupMenu;
N1: TMenuItem;
N2: TMenuItem;
procedure FormCreate(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
private
{ Private declarations }
procedure CheckMenu(var Msg: TMessage); message WM_SYSCOMMAND;//标题栏菜单
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.CheckMenu(var Msg: TMessage);
var
pm: TMenuItem;
begin
for pm in pmScreen.Items do
if pm.Command = Msg.WParam then
begin
pm.Click;
Exit;
end;
inherited;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
AppendMenu(GetSystemMenu(Handle, False), MF_POPUP or MF_STRING or MF_ENABLED,
pmScreen.Handle, '标题栏选项');
end;
procedure TForm1.N1Click(Sender: TObject);
begin
ShowMessage('OK');
end;
procedure TForm1.N2Click(Sender: TObject);
begin
close;
end;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus;
type
TForm1 = class(TForm)
PopupMenu1: TPopupMenu;
procedure FormCreate(Sender: TObject);
procedure Exit11Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure WMSysCommand(var Msg:TWMSysCommand);message WM_SysCommand;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.WMSysCommand (var Msg: TWMSysCommand);
var
Item:TMenuItem;
begin
Item := popupmenu1.FindItem (Msg.CmdType, fkCommand);
if Item <> nil then
Item.Click;
inherited;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
I:Integer;
begin
AppendMenu (GetSystemMenu (Handle, FALSE), MF_SEPARATOR, 0, '');
with popupmenu1 do
begin
for I := 0 to Items.Count - 1 do
AppendMenu(GetSystemMenu(self.Handle,FALSE),mf_Popup,
Items[I].Handle,PAnsiChar(Items[I].Caption));
end;
end;
procedure TForm1.Exit11Click(Sender: TObject);
begin
close;
end;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus;
type
TForm1 = class(TForm)
PopupMenu1: TPopupMenu;
File11: TMenuItem;
Exit11: TMenuItem;
procedure Exit1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Exit11Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure WMSysCommand(var Msg:TWMSysCommand);message WM_SysCommand;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.WMSysCommand (var Msg: TWMSysCommand);
var
Item:TMenuItem;
begin
Item := popupmenu1.FindItem (Msg.CmdType, fkCommand);
if Item <> nil then
Item.Click;
inherited;
end;
procedure TForm1.Exit1Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
I:Integer;
begin
AppendMenu (GetSystemMenu (Handle, FALSE), MF_SEPARATOR, 0, '');
with popupmenu1 do
begin
for I := 0 to Items.Count - 1 do
AppendMenu(GetSystemMenu(self.Handle,FALSE),mf_Popup,
Items[I].Handle,PAnsiChar(Items[I].Caption));
end;
end;
procedure TForm1.Exit11Click(Sender: TObject);
begin
close;
end;
end.