Solved

URGENT: TPopupMenu question

Posted on 2003-11-21
7
282 Views
Last Modified: 2010-04-05
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.
0
Comment
Question by:klompen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 3

Expert Comment

by:raidos
ID: 9796317
If the Enable1Click event is assigned to a TMenuItem then the sender will not be a TImage and TImage(Sender).Enabled := TRUE will likely fail...perhaps...i don't really understand what your trying to do...so it makes it hard to give a concrete working example..;(

Regards
//raidos
0
 

Author Comment

by:klompen
ID: 9796341
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.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 9796349
>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 ;-)



0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 11

Accepted Solution

by:
ZhaawZ earned 35 total points
ID: 9796360
the name of component is be stored in PopupMenu1.PopupComponent.Name, so you can use
TImage(FindComponent(PopupMenu1.PopupComponent.Name)).Enabled := False;

:)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 9796392
nono, ZhaawZ, not only the name, the complete refernce

an access could be

if (popupmenu1.popupcomoponent is TImage) then
  TImage(popupmenu1.popupcomoponent).Enabled := ...

meikl ;-)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 9796396
typo
popupcomoponent -> popupcomponent
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 9796402
as it will be
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month4 days, 7 hours left to enroll

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question