Solved

Changing MenuItem at RunTime

Posted on 1997-05-15
6
441 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

Suggested Solutions

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…

739 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