TPopupMenu1的用法 ( 积分: 10 )

  • 主题发起人 主题发起人 rxp2001
  • 开始时间 开始时间
R

rxp2001

Unregistered / Unconfirmed
GUEST, unregistred user!
TPopupMenu1有很多子项,当点击某一个子项,如何获取该项目的信息?
 
TPopupMenu1有很多子项,当点击某一个子项,如何获取该项目的信息?
 
不知道你想要的是不是这样的效果,也不知道你想取得的项目信息是什么:
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.
 
接受答案了.
 
后退
顶部