我把代码贴出来吧。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus,
dbctrls, comctrls, FRDBGrid, db, dbtables;
type
TFRPopupMenu = class(TPopupMenu)
private
FPMnuDBEditUndoAll: TMenuItem;
protected
public
property PMnuDBEditUndoAll: TMenuItem
Read FPMnuDBEditUndoAll Write FPMnuDBEditUndoAll;
constructor Create(AOwner: TComponent); override;
// Create Default MenuItem
Procedure FRCreatePopupMenuItem;
// Set PopupMenuItem
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Test', [TFRPopupMenu]);
end;
constructor TFRPopupMenu.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
// 问题就在这里
FRCreatePopupMenuItem;
End;
Procedure TFRPopupMenu.FRCreatePopupMenuItem;
Var
I: Integer;
SrcComponet:TComponent;
Begin
PMnuDBEditUndoAll:= TMenuItem.Create(Owner);
PMnuDBEditUndoAll.Caption := '取消';
PMnuDBEditUndoAll.Name:='PMnuDBEditUndoAll';
Items.Add(PMnuDBEditUndoAll);
UpdateItems;
End;
end.