不知道你想要的是不是这样的效果,也不知道你想取得的项目信息是什么:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Menus;
type
TForm1 = class(TForm)
pm1: TPopupMenu;
N11: TMenuItem;
w1: TMenuItem;
f1: TMenuItem;
N51: TMenuItem;
N71: TMenuItem;
btn1: TButton;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
procedure MenuItemClick(Sender: TObject);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.MenuItemClick(Sender: TObject);
begin
if Sender is TMenuItem then
begin
ShowMessage((Sender as TMenuItem).Name);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
I: Integer;
begin
for I := 0 to pm1.Items.Count - 1 do
pm1.Items.OnClick := MenuItemClick;
end;
end.