Solved

Changing MenuItem at RunTime

Posted on 1997-05-15
6
425 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
  • 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now