1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| unit TestCompo;
interface
uses
SysUtils, Classes, Controls, Types,Forms, Messages, dialogs, MonCompo, unitConfig1;
type
TTestCompo = class(TMonCompo)
private
FPopMenu: TPopupMenu;
FrmConfig1 : TFormConfig1;
procedure mnuConfig1(Sender: TObject);
protected
procedure WMRButtonDown(var Message: TWMRButtonDown); message WM_RBUTTONDOWN;
public
maVariable : string;
constructor Create(AOwner:TComponent);override;
Destructor Destroy;override;
published
property PopMenu: TPopupMenu read FPopMenu write FPopMenu;
end;
implementation
Constructor TTestCompo.Create(AOwner:TComponent);
var i : integer;
Begin
inherited Create(Aowner);
Frmconfig1 := TFormconfig1.Create(self);
FPopMenu :=NewPopupMenu(Self,'MyPopupMenu',paLeft, False,
[NewItem('Config1',0,False,True,mnuConfig1,0,'Item1')]);
End;
Destructor TTestCompo.Destroy;
Begin
Frmconfig1.Release;
inherited Destroy;
End;
procedure TTestCompo.WMRButtonDown(var Message: TWMRButtonDown);
var Pnt : TPoint;
begin
Pnt.X := Message.XPos; Pnt.Y := Message.YPos;
Pnt := ClientToScreen(pnt);
FPopMenu.Popup(Pnt.X, Pnt.Y);
End;
procedure TTestCompo.mnuConfig1(Sender: TObject);
begin
FrmConfig1.showmodal;
Mavariable:=FrmConfig1.Edit2.Text;
End;
end. |
Partager