扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
![]() 图1 添加组件后的窗体 |
procedure TForm1.FormCreate(Sender: TObject); var I: Integer; begin AppendMenu (GetSystemMenu (Handle, FALSE), MF_SEPARATOR, 0, ''); with MainMenu1 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.WMSysCommand (var Msg: TWMSysCommand); var Item: TMenuItem; begin Item := MainMenu1.FindItem(Msg.CmdType, fkCommand); if Item <> nil then Item.Click; inherited; end; |
unit Unit1; interface uses SysUtils, Windows, Messages, Classes, Graphics, Controls, Forms, Dialogs, Menus, StdCtrls; type TForm1 = class(TForm) MainMenu1: TMainMenu; File1: TMenuItem; Exit1: TMenuItem; procedure Exit1Click(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private declarations } public 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 := MainMenu1.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 MainMenu1 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; end. |
![]() 图2 程序运行结果 |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。