Solved

Changing MenuItem at RunTime

Posted on 1997-05-15
6
444 Views
Last Modified: 2010-04-04
How do you change a menuItem at Runtime.
I want to change the TMenuItem.Caption
component and refresh it. At RunTime.
Delphi seems to not allow this for some unknown
reason, I am using Delphi 1.0
0
Comment
Question by:Robert Gilland
[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
  • 3
  • 2
6 Comments
 
LVL 1

Expert Comment

by:sleach
ID: 1336314
MenuItem.caption := 'NewCaption';

The above line works fine.  You CAN change the caption at runtime.  I just tested this to verify.

I suggest that you delete all temp files, and do a rebuild.  That will sometimes fix strange errors.
0
 

Author Comment

by:Robert Gilland
ID: 1336315
Edited text of question
0
 

Author Comment

by:Robert Gilland
ID: 1336316
I know I cant or else I wouldnt ask the
question. Maybe in Delphi 2 and above you can
but in Delphi 1 you cant.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:slp
ID: 1336317
sleach's suggestion seems to work fine for me in D1, I just created a new form with a TMainMenu, inserted the "File" menu template, then added a button to the form and put this as the OnClick event handler:

procedure TForm1.Button1Click(Sender: TObject);
begin
  New1.Caption := 'Newer' ;
end;

I run the program, the "File" menu shows normally with "New" as the first item, I click the button, now the first item has become "Newer" just as would be expected.  Is this not what you're referring to when you ask "How do you change a menuItem at Runtime?"  If it is and still isn't working, can you maybe post some source code so we can see more precisely how you're doing this?

SLP

0
 
LVL 1

Accepted Solution

by:
sleach earned 50 total points
ID: 1336318
MenuItem1.caption := 'NewCaption';

I have tested the above line in both Delphi 1 & Delphi 2.
Both work fine.

Did you delete all temp files, and rebuild?
If not, you should try that...
0
 

Author Comment

by:Robert Gilland
ID: 1336319
I found the problem was that I was changing the caption
is tne OnClick event of the CLOSEBUTTON the event for
some reason did not actually occur, and I needed to change the
caption from within the unit I had the menu object in.

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses
Course of the Month6 days, 11 hours left to enroll

623 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