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

How do you view hidden form elements in Borland C++ Builder 6???

Hi,

I have a tabbed dialog form in a GUI application, and the form is only made visible if a button is clicked.  (I have taken over this application, so I am not familiar w/ its design, nor am I familiar w/ BCB.  But I am familiar w/ IDE's.)  How can I see the tabbed form (and the controls it contains) in the form designer so that I can make changes???  I am at my wit's end w/ this problem -- any help will be much appreciated.  Currently, I am resorting to directly editing the text resource file which has the extension .dfm.

Many thanks -

Todd
0
toddsab
Asked:
toddsab
  • 11
  • 11
  • 4
1 Solution
 
kode99Commented:
Normally when you open the source file from the project manager it will show the form automatically.

I wonder if the form's position is off the screen.  It will pop it up off-screen no problem or indication that it has done so.  I have run across this when I switch from my normal multi-monitor display to a portable.  To check/fix this just adjust the top and left numbers to something low enough to put it on your screen.  It's a simple thing that certainly caught me off guard.

You would need to find the form by using the object inspector.  Just look for the name that matches the class in the source file or is descended from TForm.  You could probably find these easily in the file and do a direct edit as well.

This is about the only time iv'e not had a form show up without also getting some kind of error message.

Hope it helps.

0
 
toddsabAuthor Commented:
kode99, the form is visible, but there are several layers of pages on the form.  During run time, they become active when selected by buttons that are always visible.  So if I click on button1, I get page1 to the right of the button, but if I click on button2, I get page2 in the *same* place.  The problem is, at design time, page1 keeps page2 hidden.  I need to send page1 back to be able to view page2.  And there are many pages!!!  It's a major hassle.

Thanks -

Todd
0
 
George TokasCommented:
Open Project Manager from View.
All source files related to the project are there along with the forms..
What you are describing is page or form related??
If it is form related you will see the form at the project manager.
Or is it a page control??
If it is a page control then with right click over the page you will see previous and next options along with new option.

gtokas.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
George TokasCommented:
TabControl on the other hand differs...
The tab names can be created at runtime..
But the design of the inside of the control (contain other controls I mean) has to be generic or runtime created...
So there are 2 options.
A generic design with all controls needed as default and make visible only what you need at runtime or:
A runtime created tab and the controls.

I think it has to be the first option in this case because the second require MANY things to be covered...

gtokas.
0
 
kode99Commented:
Unfortunatly I think he us using the TTabcontrol.  The page control is easier to work with as you can just page through it or set the current page to page X or use the tabs at design time.  

The 'send to back' method is the only way to work with the TTabcontrol and pages as they are (from the sound of it).  Well okay not only,  you could move the one you want to be the last page in the text version of the form (right click->View as Text,  find the object for the panel and cut and paste it to the last one in the list, which may be what you are allready doing when you are editing the dfm file),  though doing that is probably more trouble than the 'send to back' method.  

You might be able to cut and paste all the controls into the pages on a TPageControl fairly painlessly.  It would solve your issue and may require almost no or only minor changes in the source.  

You could also use 'Frames' for the panels,  this would make life easier.  This way each panel or frame is on its own 'form' more or less.  So you can just open each frame up and edit it by itself.  Then your program combines these frames onto the page and uses the Tabcontrol to set which frame to show.  Though this type of change is a lot more work it does leave you with a bunch of very modular panels.  Though this approach is likely going to be more work than switching to a page control.

It sounds like you are talking about quite a few panels so changing things may not be a trivial task just because of the quantity.  If you have a lot of work to do or are going to be maintaining it for a long term it may be worth it in saved time down the road.
0
 
toddsabAuthor Commented:
Thank you kode99.  I had a feeling Frames was the way the code should have been written in the first place.  The current developer does exactly what you mention, i.e. edit the dfm file in text mode to move things out of the way.

Thanks again -

Todd
0
 
toddsabAuthor Commented:
kode99,

I just tried to experiment w/ Frames and it was a nightmare!  I followed the example in the book Borland Developer's Guide (by Cashman).  The example was not clear, so I just tried to add a basic form using the IDE.  The form did not show up, and I have no idea why.  Even if it had shown up, I wouldn't know why it did.  So as you'll guess, I am frustrated, lost, and disgusted w/ this feature.

I would appreciate it if you could expand on the TPageControl option you have listed above, if you have time.  If you'd like I will be happy to post another question for you.

Thank you once more.

Todd
0
 
George TokasCommented:
>>so I just tried to add a basic form using the IDE.  The form did not show up, and I have no idea why.
Except of the main form the project's application exe DO NOT show any other...
You have to show them yourself programmaticaly using FormX->Show() or ShowModal()...
The difference between the 2 functions is that ShowModal() function WAITS for the form to close before execute the next line...
0
 
George TokasCommented:
One more thing...
Consider using a TTabControl...
You can configure each of your Tabbed pages as you like...

gtokas.
0
 
toddsabAuthor Commented:
Thanks.

In TTabControl, you see the tabs - I don't want to see tabs.  I want several forms on top of each other, occupying the same real estate.  I want to show only one of them at one time.  HOWEVER, during design time, I want the development to be easy.  Currently it is not.  Currently, I have to either send all but one form to the background and work on the form I want, OR I have to move the other forms out of the way by manipulating their coordinates.  Both approaches are very cumbersome.

What I want is like the wizard functionality.  Form1 has a Next button.  If that button is pressed, Form1 disappears and Form2 appears in its place, occupying the exact same location.  Form2 has buttons Previous and Next.  If Next is pressed, Form3 appears, if Previous is pressed, Form1 reappears, and so on.

Todd
0
 
George TokasCommented:
Easy...
When Next is pressed at OnClick event the lines you have to use are:
FormX's OnClick:
{
      Form(X+1)->Show();//Show next form.
      Close();//and close the current form
}
Same and if you have a previous button...

Also if the controls at those forms are similar you can create the forms and at runtime using a file as control (buttons, edits etc) descriptor and properties setting.

gtokas.
0
 
toddsabAuthor Commented:
I appreciate your help -- HOWEVER, what you describe is the run time.  My problem is w/ the design of the overlapping pages.  Since they occupy the same coordinates, how do I manage their design???  Can you be more specific?  What do you mean by using a file as control descriptor?
0
 
George TokasCommented:
First of all a working example:
http://www.millenia2006.com
Download and run the installer.
It consists of 4 forms.
The main one and 3 others.
The first opens and downloads a licence file and display it on a RichEdit component.
By pressing Next the form close and the next one appears for some checks at OS, DirectX and more.
When and this one finish by pressing next closes and the last one opens to download some core files.
To get rid of the application if you install:
Open regedit and at:
HKLM\Software......\Run\
Delete the entry Millenia2006.
Open taskmanager and kill proccess Monitor.exe

That was what I described first.

The second is a bit more complex.
Create a text file and start adding entries as follows in example:
[form2:500:500:0:0]//name of the form,width,height,top,left
[TButton:Close:100:100]//A Button named "Close" at coordinates x=100,y=100
[TButton:Next:10:10]
....
....
At design time in your code you can instruct what to do in runtime.
So you can instruct to create a new form using:
TForm  *Form2 = new TForm(Application);
Form2->Width = ...//The value from the file
....//Set values here
Each control like buttons have to set the coresponding event handlers because we want them to work but they can categorized. All close button can be directed in the same function in example....
I think you get the idea.
This way the final exe will be smaller in size but requires A LOT of consideration and CAUTION...
If you never did something like it is not advised.
I am a bit experienced programmer but the most of the times I use the first method.

gtokas.
0
 
toddsabAuthor Commented:
When I do the installation, will I be getting source code, or a runtime idea of how it works?
0
 
George TokasCommented:
Test it first and then we will see...
maybe you don't need it...:-)
But if you like I can post and code...

gtokas.

P.S.
>>To get rid of the application if you install:
thats because I don't made the uninstaller YET....:-)
0
 
toddsabAuthor Commented:
Would be great if you could just post the code - again, I am interested in the design time elements.
0
 
George TokasCommented:
Not a great deal...
All 3 forms you saw are parts of the project using File|New Form.
The important is to add:

#include <vcl.h>
#pragma hdrstop

#include "Unit2.h"
#include "MainFormsMain.h" //THIS LINE IS IMPORTANT!!!!

And aldo at the mainform's header add the headers of the rest of the forms you are using...
//Main Header file:
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ComCtrls.hpp>
#include "Unit2.h"
#include "Unit3.h"
#include "unit4.h"
#include <ExtCtrls.hpp>

//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:      // IDE-managed Components


The first form you see have 2 buttons, a checkbox, a RichEdit and a TNMHTTP.
OnActivate is downloading the licence file and display it.
By Clicking Next I'm showing the next (Form3) form and closing this one using the part I posted before.

Next form except of those you see its just a TTimer...
Same thing to close and show the last...

The last just downloads 4 files and make the change at the registry...

Not a big deal...
Try it this way and see...
By the way:
I'm using an extra and hidden form as main because I want a main form to be opened ALL the time...
The secondary forms are LINKED to the main one and thats why I choose this approach....

gtokas.
0
 
George TokasCommented:
Also at the project's cpp file:
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
        try
        {
                 Application->Initialize();
                 Application->ShowMainForm = false;//this way main form is created hidden
                 Application->CreateForm(__classid(TForm1), &Form1);
                 Application->CreateForm(__classid(TForm2), &Form2);
                 Application->CreateForm(__classid(TForm3), &Form3);
                 Application->CreateForm(__classid(TForm4), &Form4);
                 Application->Run();
        }
        catch (Exception &exception)

And something else I forgot:
I have a TTimer at main form enabled.
When it ticks:
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
        Timer1->Enabled = false;//Disabling the timer because I don't need it again
        Form1->Hide();//If accidentally the form is displayed hide it.
        Form2->Show();//And now show the nexy one for the licence file.
}
//---------------------------------------------------------------------------

gtokas.
0
 
kode99Commented:
To use the frames at design time you must first create the frame (File->NewFrame) just like you would make a regular form.  Stick some stuff on it and save it.  This frame is now basically a custom panel type component.

Now when you click the 'Frames' button in the componet bar it will show you a list of the frames for this project,  pick the one you just made and now the frame you created should show in your main form.  Save the main form and build and run the project and you will see your main form with the frame showing in it.

Now go make a change to the frame you created and recompile the program and run it.  You will see the changes you made to the frame module are automatically done to all instances of it in the program.  So once you place these in the main form you never need to even open the main form again to edit them.  The problem of which is on top is irrelevant because you open each frame individually to make changes to it - so no more juggling whos on top.

Now to control which frame will be seen you will notice in the object inspector that each frame has a Visible property.  It you toggle this at runtime it will allow you to control which is actually going to show.  So if you layered 10 of these frames in the main form just flip the Visible to true for the one that needs to be displayed.  If you dont need the tabs to show you dont even need to use the tab control at all - all this does is provide a easy user interface to allow toggling the Visible property.

The complexity with frames is they are really like components on a form.  This means that you may need to write code to interact with them.  If you can get away with most of the code being in the actual frame it is simple but if you have a lot of interaction between the main form and your frame or between multiple frames it will be extral work.

To use the page control all you need to do is slap a page control down,  right click on it and create the pages and then cut and paste the GUI from the original panels into the pages of the page control.

One warning about this,  do not use frames inside page controls there seem to be some issues there so stick with one or the other.  In theory you should be able to nest TPageControls and TFrame's but I have found that it did not work out too well.

Heres a chapter on TFrame,  its not exactly doing what you want but maybe it will help you understand frames.
http://www.samspublishing.com/articles/article.asp?p=31668&seqNum=4&rl=1
0
 
toddsabAuthor Commented:
gtokas and kode99,

Thank you both for sticking w/ this closed question, but after reviewing both your comments, I am giving up on this task.  It's too difficult for me and I feel it's not worth the effort.

BCB has left a sour taste in my mouth, though.

Thank you again -

Regards,

Todd
0
 
George TokasCommented:
>>BCB has left a sour taste in my mouth, though.
I think that you give up very easily...
BCB is a GREAT RAD tool...
>>It's too difficult for me and I feel it's not worth the effort.
I think it's easy following my post's directions...
It is a working example anyway...
It will be better to start using something easier, like a beep when a new form appears, controled by a timer enabled when a form is displayed...
It will be a good starting point to add functionality later on...

George Tokas.
0
 
toddsabAuthor Commented:
George, thank you, I really appreciate your continued interest and support.  Do you think you could send me the full version of your project to soper43 at yahoo dot com?

Regards,

Todd
0
 
George TokasCommented:
I will modify the source a bit and I will send it but later...
I will make some comments at the code...
It is BCB6 project...

George Tokas.
0
 
toddsabAuthor Commented:
THANK YOU!
0
 
kode99Commented:
It's probably a bit of a steep learning curve to have to 'fix' something that was laid out in a poor fashion in the first place, or at least did not make use of the strengths of the BCB RAD and the VCL.  Rather a rough intro to the tool.

Given your description of this one aspect I would guess that you are going to come across a few other poor design choices.

I would recommend the BCB Developers guide (same one I linked above) as well there was a 'Teach yourself CBuilder' as books that would help get you up to speed quickly.

Once you get a handle on the VCL you will never want to build a GUI with anything else.


0
 
toddsabAuthor Commented:
kode99, I felt as I though I let you guys down by giving up, but see it my way: even the book you mention points out that the Panel feature in BCB has faults.

The other thing is, I am a very experienced developer.  I feel that if I can't make my way out of this mess, the problem is not me but the tool.

However, you are also right in that the original design was very poorly done.  The junior developer in charge of the maintenance currently works by modifying the dfm file by hand to change all the coordinates so that the rest of the components move out of the way, and he's left w/ the one which becomes visible (i.e. of the overlapping pages).  I felt sorry for him and wanted to step in as an experienced engineer to find a fix, and yet I could not.

Thanks again.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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