• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 929
  • Last Modified:

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
0
auk_ie
Asked:
auk_ie
  • 5
  • 4
1 Solution
 
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.

0
 
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. )
0
 
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
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
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.

0
 
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).
0
 
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.
0
 
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.

0
 
auk_ieAuthor Commented:
I just want to know where is this functionality coming from
0
 
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.
0
 
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now