使用API动态添加删除菜单项
使用API動(dòng)態(tài)添加刪除菜單項(xiàng)
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
??? Button1: TButton;
??? procedure FormCreate(Sender: TObject);
??? procedure Button1Click(Sender: TObject);
private
??? { Private declarations }
??? hMenu,hPopMenu1,hPopMenu2:HMENU;
public
??? { Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
hMenu:=CreateMenu();
hPopMenu1:=CreateMenu();
hPopMenu2:=CreateMenu();
AppendMenu(hPopMenu1,MF_STRING,40001,'New');
AppendMenu(hPopMenu1,MF_STRING,40002,'Open');
AppendMenu(hPopMenu2,MF_STRING,40005,'About');
AppendMenu(hPopMenu1,MF_POPUP, hPopMenu2, 'Help');
AppendMenu(hMenu,MF_POPUP,hPopMenu1,'&File');
SetMenu(self.Handle,hMenu);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
DeleteMenu(hPopMenu1,2,MF_BYPOSITION);
end;
end.
轉(zhuǎn)載于:https://www.cnblogs.com/webcyz/archive/2012/11/13/2767875.html
總結(jié)
以上是生活随笔為你收集整理的使用API动态添加删除菜单项的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: ThinkPHP框架使用心得二 CURD
- 下一篇: 串行接口