Solved

Changing MenuItem at RunTime

Posted on 1997-05-15
6
431 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi XE2 application frozen on Windows 10 10 270
code issue 8 99
error 1.1 400 Bad request idhttp delphi 18 54
how to change, disabled button color FMX ? 1 13
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

911 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

16 Experts available now in Live!

Get 1:1 Help Now