Board index » delphi » PopupMenu

PopupMenu

I have a form with several DBLookupComboBoxes. I have assigned
these controls a PopupMenu with one option, "Disable".

In the menu click event handler, I would like to disable the combobox
which was under the mouse when the popup-menu was brought up. But the
Sender parameter of the PopupMenu's OnClick procedure merely points
back to the menu item, not the control which "originated" the menu.

Is there any way to find out which control the user right-clicked on,
and bring this into the popupmenu OnClick handler?

- Morten

 

Re:PopupMenu


In article <3680E32D.8D5FA...@statoil.com>, "Morten Br?ten" <mo...@statoil.com>
writes:

Quote
>Is there any way to find out which control the user right-clicked on,
>and bring this into the popupmenu OnClick handler?

From Delphi TPopUpMenu help :-

"property PopupComponent: TComponent;

Description

Run-time only. The PopupComponent property refers to of the component the user
clicked on to display the pop-up menu. If your application has multiple
controls that share the same pop-up menu, you can use PopupComponent to
determine which of them displayed the menu.
"

Alan Lloyd
alangll...@aol.com

Re:PopupMenu


On Wed, 23 Dec 1998 13:33:49 +0100, "Morten Br?ten"

Quote
<mo...@statoil.com> wrote:
>Is there any way to find out which control the user right-clicked on,
>and bring this into the popupmenu OnClick handler?

Hi Morten, try this:

procedure TForm1.AnyClick1(Sender: TObject);
begin
  if (PopUpMenu1.PopupComponent is TComboBox) then
    (PopUpMenu1.PopupComponent as TComboBox).ItemIndex:=-1;

  if (PopUpMenu1.PopupComponent is TEdit) then
    (PopUpMenu1.PopupComponent as TEdit).Text:='';
end;

- Ulli -

The Coder's Knowledge Base
http://www.netalive.org/ckb

Other Threads