W
wind1
Unregistered / Unconfirmed
GUEST, unregistred user!
自建组件程序如下
unit myMainMenu;
interface
uses
Windows,
Messages,
SysUtils,
Classes,
Graphics,
Controls,
Forms,
Dialogs,
Menus;
type
TmyMainMenu = class(TMainMenu)
private
witem:TMenuItem;
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
published
{ Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('myMenu', [TmyMainMenu]);
end;
{ TMiracleMainMenu }
constructor TMiracleMainMenu.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
witem := TMenuItem.Create(Self);
witem.Caption :='123';
Items.Add (witem);
UpdateItems;
end;
end.
问题出来了,当我运行程序的时候,菜单项变成了一模一样的两个,怀疑是由我的程序
建立实例前,form自动已create了一个实例,但怎么解决呢???
unit myMainMenu;
interface
uses
Windows,
Messages,
SysUtils,
Classes,
Graphics,
Controls,
Forms,
Dialogs,
Menus;
type
TmyMainMenu = class(TMainMenu)
private
witem:TMenuItem;
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
published
{ Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('myMenu', [TmyMainMenu]);
end;
{ TMiracleMainMenu }
constructor TMiracleMainMenu.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
witem := TMenuItem.Create(Self);
witem.Caption :='123';
Items.Add (witem);
UpdateItems;
end;
end.
问题出来了,当我运行程序的时候,菜单项变成了一模一样的两个,怀疑是由我的程序
建立实例前,form自动已create了一个实例,但怎么解决呢???