Solved

C++ Builder enable button

Posted on 2003-11-13
10
869 Views
Last Modified: 2009-12-16
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
Comment
Question by:auk_ie
  • 5
  • 4
10 Comments
 
LVL 13

Expert Comment

by:SteH
ID: 9746004
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
 
LVL 12

Expert Comment

by:andrewjb
ID: 9746226
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
 

Author Comment

by:auk_ie
ID: 9748650
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
 
LVL 12

Expert Comment

by:andrewjb
ID: 9748697
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
 

Author Comment

by:auk_ie
ID: 9749269
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
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 12

Expert Comment

by:andrewjb
ID: 9749341
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
 

Author Comment

by:auk_ie
ID: 9749452
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
 

Author Comment

by:auk_ie
ID: 9749454
I just want to know where is this functionality coming from
0
 
LVL 12

Accepted Solution

by:
andrewjb earned 250 total points
ID: 9749556
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
 

Author Comment

by:auk_ie
ID: 9749690
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

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
add elements to existing standard structure 2 96
SendMessage fails while PostMessage works 2 107
thread-safe code in c++ 2 84
Arduino EDI - Programming language 3 80
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

895 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

15 Experts available now in Live!

Get 1:1 Help Now