Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: TPopupMenu, Delphi 7


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 1 - Last Post: Jun 4, 2015 10:20 AM Last Post By: Remy Lebeau (Te...
Jim Sawyer

Posts: 214
Registered: 1/3/10
TPopupMenu, Delphi 7  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 4, 2015 6:53 AM
Thanks to your help a couple days ago, I am now designing a runtime context menu successfully. It is populated with years ("2001", "2002", "2003", etc.). The problem comes when I make a selection from the menu. I don't know how to know which selection was made. The code

procedure MyForm.YearClicked( Sender: TObject );
var
Yr: Word;
begin
Yr := TMenuItem( Sender ).Tag;
end;

always assigns a value of 0 to Yr so I can't tell which option was clicked. How can I correct this problem?

Thanks,
Jim Sawyer, DataWare
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: TPopupMenu, Delphi 7  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 4, 2015 10:20 AM   in response to: Jim Sawyer in response to: Jim Sawyer
Jim wrote:

The code
<snip>
always assigns a value of 0 to Yr

Sorry, I forgot an important piece in my earlier example:

for I := 0 to 19 do
begin
  Item[I] := NewItem(IntToStr(Yr + I), 0, false, true, YearClicked, 0, '');
  Item[I].Tag := Yr + I; // <-- add this
end;
YearMenu.Add(Items);


--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02