popup menu

This is a discussion on popup menu within the Delphi forums in Programming Languages category; 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...

Go Back   Application Development Forum > Programming Languages > Delphi

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-05-2008, 03:31 AM
joseph
Guest
 
Default popup menu

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


Reply With Quote
  #2  
Old 08-05-2008, 03:36 AM
Jim P
Guest
 
Default Re: popup menu

joseph wrote:
> 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
>
>

There is a tag field in each component.

Jim P
Reply With Quote
  #3  
Old 08-05-2008, 06:02 AM
joseph
Guest
 
Default Re: popup menu

My problem is that clicking on a menu item the owner of the component is the
form and not the grid.


joseph

"Jim P" <Jim_P@mad.scientist.com> wrote in message
news:4898031b@newsgroups.borland.com...
> joseph wrote:
> > 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
> >
> >

> There is a tag field in each component.
>
> Jim P



Reply With Quote
  #4  
Old 08-05-2008, 06:12 AM
Peter Below (TeamB)
Guest
 
Default Re: popup menu

joseph wrote:

> 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.


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
Reply With Quote
  #5  
Old 08-05-2008, 07:22 AM
joseph
Guest
 
Default Re: popup menu

Thanks, that's what I needed.

joseph


"Peter Below (TeamB)" <none@nomail.please> wrote in message
news:xn0ftkeyc1ejdm000@newsgroups.borland.com...
> joseph wrote:
>
> > 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.

>
> 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



Reply With Quote
  #6  
Old 08-05-2008, 02:19 PM
Remy Lebeau \(TeamB\)
Guest
 
Default Re: popup menu


"joseph" <pelli@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).GetParent Menu).PopupComponent).CopyToClipboard;
end;

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

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


Gambit


Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 09:36 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.