动态创建POPUPMENUE 如题,MENUE如下,动态创建a--aabc--ccde--ee0 --ee1 --ee2f差不多是这个样子了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 一个例子:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Menus;type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); private { Private declarations } APopup : TPopupMenu; public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);begin APopup := TPopupMenu.Create(Self);end;procedure TForm1.FormDestroy(Sender: TObject);begin APopup.Free;end;procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);var AItem : TMenuItem; ASubItem: TMenuItem; APoint : TPoint;begin if Button = mbRight then begin APopup.Items.Clear; AItem := TMenuItem.Create(Self); AItem.Caption := 'a'; APopup.Items.Add(AItem); ASubItem := TMenuItem.Create(Self); ASubItem.Caption := 'aa'; AItem.Add(ASubItem); AItem := TMenuItem.Create(Self); AItem.Caption := 'b'; APopup.Items.Add(AItem); AItem := TMenuItem.Create(Self); AItem.Caption := 'c'; APopup.Items.Add(AItem); ASubItem := TMenuItem.Create(Self); ASubItem.Caption := 'cc'; AItem.Add(ASubItem); AItem := TMenuItem.Create(Self); AItem.Caption := 'd'; APopup.Items.Add(AItem); AItem := TMenuItem.Create(Self); AItem.Caption := 'e'; APopup.Items.Add(AItem); ASubItem := TMenuItem.Create(Self); ASubItem.Caption := 'ee0'; AItem.Add(ASubItem); ASubItem := TMenuItem.Create(Self); ASubItem.Caption := 'ee1'; AItem.Add(ASubItem); ASubItem := TMenuItem.Create(Self); ASubItem.Caption := 'ee2'; AItem.Add(ASubItem); GetCursorPos(APoint); APopup.Popup(APoint.X, APoint.Y); end;end;end. ACCESS里面的一个SQL语句,转化成DELPHI里面的 Delphi版历任版主照片(绝密,申请加精!) 关于DELPHI 中 OpenDataSource 的应用 高效算法求解!急!!! mediaplayer 的问题,循环播放几个影片88分钟左右后出错! 还是一个新手问题,请帮忙! 请问怎样返回整数部分 这个问题居然没人回答? 看过Web Application開發利器-WebSnap!这篇文章的高手进来讨论一下,我有一点问题。如果你在WebSnap上有经验的话也进来看一下! [转贴]DELPHI的原子世界(2) 关于stringgrid改变列宽的问题 vss和delphi
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Menus;type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
APopup : TPopupMenu;
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
APopup := TPopupMenu.Create(Self);
end;procedure TForm1.FormDestroy(Sender: TObject);
begin
APopup.Free;
end;procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
AItem : TMenuItem;
ASubItem: TMenuItem;
APoint : TPoint;
begin
if Button = mbRight then
begin
APopup.Items.Clear; AItem := TMenuItem.Create(Self);
AItem.Caption := 'a';
APopup.Items.Add(AItem);
ASubItem := TMenuItem.Create(Self);
ASubItem.Caption := 'aa';
AItem.Add(ASubItem); AItem := TMenuItem.Create(Self);
AItem.Caption := 'b';
APopup.Items.Add(AItem); AItem := TMenuItem.Create(Self);
AItem.Caption := 'c';
APopup.Items.Add(AItem);
ASubItem := TMenuItem.Create(Self);
ASubItem.Caption := 'cc';
AItem.Add(ASubItem); AItem := TMenuItem.Create(Self);
AItem.Caption := 'd';
APopup.Items.Add(AItem); AItem := TMenuItem.Create(Self);
AItem.Caption := 'e';
APopup.Items.Add(AItem);
ASubItem := TMenuItem.Create(Self);
ASubItem.Caption := 'ee0';
AItem.Add(ASubItem);
ASubItem := TMenuItem.Create(Self);
ASubItem.Caption := 'ee1';
AItem.Add(ASubItem);
ASubItem := TMenuItem.Create(Self);
ASubItem.Caption := 'ee2';
AItem.Add(ASubItem); GetCursorPos(APoint);
APopup.Popup(APoint.X, APoint.Y);
end;
end;end.