Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Pagecontrol/Tabsheets popupmenu

I have a form with a Pagecontrol.
I then add a Ttabsheet to that pagecontrol at runtime, and a Tmemo object to the new tabsheet. Here is a sample code:

*****************
procedure TForm1.Button1Click(Sender: TObject);
var ts:Ttabsheet;
begin
TS := TTabSheet.Create(self);
ts.PageControl:=pagecontrol1;
with tmemo.Create(TS) do
begin
Align := albottom;
Text := '';
Parent := TS;
popupmenu:=NIL; <---------*** I want to remove this popupmenu
end;
end;
***************************

The pagecontrol has a popupmenu assigned to itself.
The problem is that both the Tmemo and the Ttabsheet objects is also getting this popupmenu.... And I dont want that. I only want the popupmenu to popup when I click right on the tab (where the tabsheet -caption is).
What can I do ?

ALL suggestions are welcome !

Comments

  • zibadianzibadian Member Posts: 6,349
    : I have a form with a Pagecontrol.
    : I then add a Ttabsheet to that pagecontrol at runtime, and a Tmemo object to the new tabsheet. Here is a sample code:
    :
    : *****************
    : procedure TForm1.Button1Click(Sender: TObject);
    : var ts:Ttabsheet;
    : begin
    : TS := TTabSheet.Create(self);
    : ts.PageControl:=pagecontrol1;
    : with tmemo.Create(TS) do
    : begin
    : Align := albottom;
    : Text := '';
    : Parent := TS;
    : popupmenu:=NIL; <---------*** I want to remove this popupmenu
    : end;
    : end;
    : ***************************
    :
    : The pagecontrol has a popupmenu assigned to itself.
    : The problem is that both the Tmemo and the Ttabsheet objects is also getting this popupmenu.... And I dont want that. I only want the popupmenu to popup when I click right on the tab (where the tabsheet -caption is).
    : What can I do ?
    :
    : ALL suggestions are welcome !
    :
    The right-click event is probably sent from the memo to its parent. You can override this behaviour by using the following code for the Memo.OnContextPopup. I've just successfully tested it.
    [code]
    procedure TForm1.Memo1ContextPopup(Sender: TObject; MousePos: TPoint;
    var Handled: Boolean);
    begin
    Handled := true;
    end;
    [/code]
Sign In or Register to comment.