C++ Builder enable button

Hello This is a simple question

I created an MDI project, C++ Builder creates a main form child form etc. However on the main form there is a toolbar. The save button on this bar is always disabled. I can't figure out where and how these tool bar buttons are enabled and disabled. For example when I open a new document, a child window is created, when i select some text in this form the cut, copy and paste buttons become enbled.

Unfortunately the save button never becomes enabled. Anyone know where these buttons are being enabled/disabled, I can't see it in the main form code or the child form code.

Regards
auk_ieAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SteHCommented:
In a MDI app I would assume that there is something like a document class which should have a property or method called something like modified. Change this and saving should be enabled. The idea behind: A document opened not changed doesn't need to be saved and so the button is disabled. Only when it is altered it needs saving and the button is enabled. Since I don't have BCB available here I can't give you more details.

andrewjbCommented:
You need to write a handler for the action.

On the main form, there's an ActionList. Double-click this, and click on the 'FileSave1' item. Then look in object inspector, and it's got an OnExecute event. You need to put something in here.

( A simple ; will do to start with - so long as the handler exists, the button is enabled and the handler is called. The default project doesn't implement saving or loading for you, though. )
auk_ieAuthor Commented:
Hello andrewjb

The only onexecute event handlers I can see in main.cpp are

FileNew1Execute
FileOpen1Execute
HelpAbout1Execute
FileExit1Execute

I don't know where the other handlers are for the other default functionality added

for eg, In the object inspector I see the buttons have certain actions

for eg

FileOpen1
EditCopy1
FileSave1 (This is added to the save button I want to enable)
WindowCascade1...........etc.....etc

But how can I modify the functionality of any of these actions. I see them defined in the main header file as

        TAction *FileNew1;
        TAction *FileSave1;
        TAction *FileExit1;
        TAction *FileOpen1;
        TAction *FileSaveAs1;

But I have no idea as how to modify these actions. And I don't see where the actions are being implemented from.

Kind Regards
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

andrewjbCommented:
Find the ActionList on themain form.
Double-click it. This opens to show you the actions.
Find FileSave1
Dbl-click this;
That defines you an OnExecute event handler. It will initially be empty. For now, just put a ; between the { and } so the function doen's disappera.
Compile.
The save button will be enalbed, though at the moment it doesn't do anything.

auk_ieAuthor Commented:
Thanks andrew, That about answers my question, I figured this out last night, but doing it this way you loose the default functionality C++Builder added to my save button, ie FileSave1. I have to reimplement that. I only wanted to modify this function. If I had to go around and re-implement from scratch all the different actions c++builder added, that would be a pain.

I really don't understand when C++ bulider declares

TAction *FileSave1; //in the main header

and then adds FileSave1 to the action property of the save button. How does that work? Where's the implementation for the save button functionality (in essesnce so I can modify it instead of writing a new function from scratch).
andrewjbCommented:
There _is_ no implementation of the save mechanism. You have to do it yourself.... It just don't save anything. Nowhere, not ever.

The TAction you see is the one in the actionlist on the form, and you're going to have to tell it _how_ to save. How can it save when it doesn't know what data you'll be editing?

Andrew.
auk_ieAuthor Commented:
But what about the cut button, That has an action called EditCut1

again this is declared in the header as TEditCut *EditCut1;

but I can't see any implemenation for it. So I can't modify.

There is a whole list of these type of buttons and I for some reason can't see where they are implemented, the paste, copy and tile window functions are other examples.

auk_ieAuthor Commented:
I just want to know where is this functionality coming from
andrewjbCommented:
I think cut / copy etc just pass the CTRL-X etc to the memo which implements it.

'New' and 'Open' are implemented in code.

Others aren't implemented at all - go into the action manager, find the action, and dbl-click to define your own procedure.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
auk_ieAuthor Commented:
So basically the default functionality can't be modified, what a pain! Thanks anyway.

Andrew will you look at another question for me please,

The URL is

http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_20798366.html
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.