klompen
asked on
URGENT: TPopupMenu question
If I have several TImage component, is it possible that each of that TImage component is using the same TPopupMenu ?
So I dont have to create popupmenu for every component.
I tried like this :
// clicking one of the popup menu item
procedure TForm1.Enable1Click(Sender : TObject);
begin
TImage(Sender).Enable := TRUE;
end;
But I got "Access Violation" error.
Please help me.
So I dont have to create popupmenu for every component.
I tried like this :
// clicking one of the popup menu item
procedure TForm1.Enable1Click(Sender
begin
TImage(Sender).Enable := TRUE;
end;
But I got "Access Violation" error.
Please help me.
ASKER
Here is the situation :
I have several TImage objects in a form :
Image1: Timage;
Image2: Timage;
Image3: Timage;
And I have one TPopupMenu object :
Popup1: TPopupMenu;
Enable1: TMenuItem;
Disable1: TMenuItem;
What I need to do is, assigning all those TImage objects PopupMenu property to the above Popup1. So I dont have to create 3 TPopupmenu objects for each TImage object.
Then, I should check WHICH Timage object triggered the Popup1 ?
That's my question.
I have several TImage objects in a form :
Image1: Timage;
Image2: Timage;
Image3: Timage;
And I have one TPopupMenu object :
Popup1: TPopupMenu;
Enable1: TMenuItem;
Disable1: TMenuItem;
What I need to do is, assigning all those TImage objects PopupMenu property to the above Popup1. So I dont have to create 3 TPopupmenu objects for each TImage object.
Then, I should check WHICH Timage object triggered the Popup1 ?
That's my question.
>is it possible that each of that TImage component is
>using the same TPopupMenu ?
yes, just assign it to each timage-popupmenu-property
>But I got "Access Violation" error.
as raidos already explained the sender is the menuitem
the popupmenu has a property popupcompenent,
there is stored which component caused the popup,
just store it in a var in the onpopup-event,
so you can use it in your menuitem-onclick event
meikl ;-)
>using the same TPopupMenu ?
yes, just assign it to each timage-popupmenu-property
>But I got "Access Violation" error.
as raidos already explained the sender is the menuitem
the popupmenu has a property popupcompenent,
there is stored which component caused the popup,
just store it in a var in the onpopup-event,
so you can use it in your menuitem-onclick event
meikl ;-)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
nono, ZhaawZ, not only the name, the complete refernce
an access could be
if (popupmenu1.popupcomoponen t is TImage) then
TImage(popupmenu1.popupcom oponent).E nabled := ...
meikl ;-)
an access could be
if (popupmenu1.popupcomoponen
TImage(popupmenu1.popupcom
meikl ;-)
typo
popupcomoponent -> popupcomponent
popupcomoponent -> popupcomponent
as it will be
Regards
//raidos