Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

popup menu

0 views
Skip to first unread message

joseph

unread,
Aug 5, 2008, 3:31:50 AM8/5/08
to
Is there a way to get the component which is using/invoking the popup menu?

Example:
Popup menu is assigned to many TStringGrid Components. On click of a menu
item of a component I want to type cast the TStringGrid like
TStringGrid(Owner).CopyToClipBoard.

Delphi 6

joseph


Jim P

unread,
Aug 5, 2008, 3:36:59 AM8/5/08
to
There is a tag field in each component.

Jim P

joseph

unread,
Aug 5, 2008, 6:02:11 AM8/5/08
to
My problem is that clicking on a menu item the owner of the component is the
form and not the grid.


joseph

"Jim P" <Ji...@mad.scientist.com> wrote in message
news:4898...@newsgroups.borland.com...

Peter Below (TeamB)

unread,
Aug 5, 2008, 6:12:08 AM8/5/08
to
joseph wrote:

The TPopupMenu component has a PopupComponent property for exactly this
purpose.

--
Peter Below (TeamB)
Don't be a vampire (http://slash7.com/pages/vampires),
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com

joseph

unread,
Aug 5, 2008, 7:22:12 AM8/5/08
to
Thanks, that's what I needed.

joseph


"Peter Below (TeamB)" <no...@nomail.please> wrote in message
news:xn0ftkey...@newsgroups.borland.com...

Remy Lebeau (TeamB)

unread,
Aug 5, 2008, 2:19:22 PM8/5/08
to

"joseph" <pe...@euroweb.net.mt> wrote in message
news:489801ed$1...@newsgroups.borland.com...

> Is there a way to get the component which is using/invoking the popup
> menu?

TPopupMenu has a PopupComponent property for that exact purpose.

> Popup menu is assigned to many TStringGrid Components. On click
> of a menu item of a component I want to type cast the TStringGrid
> like TStringGrid(Owner).CopyToClipBoard.

procedure TForm1.CopyMenuItemClick(Sender: TObject);
begin
TStringGrid(TPopupMenu(TMenuItem(Sender).GetParentMenu).PopupComponent).CopyToClipboard;
end;

Or, if you already know which TPopupMenu ahead of time:

procedure TForm1.CopyMenuItemClick(Sender: TObject);
begin
TStringGrid(PopupMenu1.PopupComponent).CopyToClipboard;
end;


Gambit


0 new messages