换一个名字,到下面看一看:
http://burks.bton.ac.uk/burks/language/pascal/devfaq/
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls, Menus;
type
TForm1 = class(TForm)
RichEdit1: TRichEdit;
OpenDialog1: TOpenDialog;
Button3: TButton;
MainMenu1: TMainMenu;
procedure Button1Click(Sender: TObject);
procedure FileOpen(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
NewItem: TMenuItem;
I : integer;
begin
{ first create the separator }
NewItem := TMenuItem.Create(Self);
NewItem.Caption := '-';
{ add the new item to the Windows menu }
// MainMenu1.Add(NewItem);
{ now create and add a menu item for each form }
for I := 0 to Screen.FormCount-1 do
begin
NewItem := TMenuItem.Create(Self);
NewItem.Caption := Screen.Forms.Name;
// Windows.Add(NewItem);
end;
end;
{var
Newitem:Tmenuitem;
I:integer;
begin
Newitem:=TmenuItem.create(Self);
Newitem.caption:=Form1.Name;
Newitem.Onclick:=fileopen;
end;}
procedure TForm1.FileOpen(Sender: TObject);
begin
if OpenDialog1.Execute then
begin
//PerformFileOpen(OpenDialog.FileName);
richEdit1.lines.loadfromfile(OpenDialog1.filename);
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
var
newitem : Tmenuitem;
begin
newitem:=tmenuitem.create(Mainmenu1);
newitem.caption:='111';
mainmenu1.items.insert(mainmenu1.items.count,newitem);
Newitem.Onclick:=fileopen;
end;
end.