Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

C++ Builder enable button

Posted on 2003-11-13
10
875 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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
 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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 viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

840 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