 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Barry Guest
|
Posted: Thu Mar 24, 2005 7:24 pm Post subject: Using Frames |
|
|
I have created a frame on a form. In use, this form is called with ->ShowModal() and so far, all works well. When I click on an "Advanced" button which I created, I want the frame to become visible and accessible, but I have not been able to get this to work. I have tried FrameName->Show, ->Visible = true, etc. and both generate exception errors. I have not been able to find any sufficient references to this in the documentation. Any thoughts? TIA
|
|
| Back to top |
|
 |
Vladimir Stefanovic Guest
|
Posted: Thu Mar 24, 2005 8:08 pm Post subject: Re: Using Frames |
|
|
Please wrap your lines manually. It's much easier to make
selective answers to your questions. Thank you.
TFrame is a container for visual controls (like TForm), contrary
to TDataModule which is a container for non-visual controls.
Contrary to TForm, TFrame is *not intended* to be shown
independently. It has to be imbedded into some other control
(which can be on TForm). Look at the only 'direct' propery
of TFrame (derived from TCustomFrame). It's 'Parent'.
So, it's easy to understand that you 'show' your TFrame something
like this:
1) Frame2->Parent = this; // Assign to, say, Form1
2) Frame2->Parent = Panel1; // Assign to Panel1
3) Frame2->Parent = TabSheet1; // Assign to TabSheet1
etc...
Here's a simple example / UNTESTED /:
1) make a Unit1 / Form1
a) add Panel1
b) add Button1
2) make a Unit2 / Frame2
a) add Memo1
b) align Memo1, alClient
Look at Project/Options/Forms and move Frame2 to
Available section (if it's not moved automatically).
--- Unit1.cpp ---
#include "Unit2.h" // Because of Frame2
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
Frame2 = new TFrame2 ( this );
}
__fastcall TForm1::~TForm1()
{
delete Frame2;
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Frame2->Parent = Panel1;
}
--- Unit1.h ---
// added...
__fastcall ~TForm1();
--- Unit2.cpp & Unit2.h ---
// no code, just the design-time changes
--
Best regards,
Vladimir Stefanovic
|
|
| Back to top |
|
 |
Barry Guest
|
Posted: Fri Mar 25, 2005 1:04 pm Post subject: Re: Using Frames |
|
|
Thanks for the advice. I tried it, but must be missing something since it didn't work.
I created Frame2 and it is listed as available in Project options. I also made sure that it's visible property is set to true.
I have another form open and created Panel8 on it as well as a button. My followup code is
.....ButtonClick(TObject *Sender)
{
Frame2->Parent = Panel8;
Panel8->Visible = true;
etc.
I guess I just don't understand something simple.
"Vladimir Stefanovic" <antivari (AT) po (DOT) sbb.co.yu> wrote:
| Quote: | Please wrap your lines manually. It's much easier to make
selective answers to your questions. Thank you.
TFrame is a container for visual controls (like TForm), contrary
to TDataModule which is a container for non-visual controls.
Contrary to TForm, TFrame is *not intended* to be shown
independently. It has to be imbedded into some other control
(which can be on TForm). Look at the only 'direct' propery
of TFrame (derived from TCustomFrame). It's 'Parent'.
So, it's easy to understand that you 'show' your TFrame something
like this:
1) Frame2->Parent = this; // Assign to, say, Form1
2) Frame2->Parent = Panel1; // Assign to Panel1
3) Frame2->Parent = TabSheet1; // Assign to TabSheet1
etc...
Here's a simple example / UNTESTED /:
1) make a Unit1 / Form1
a) add Panel1
b) add Button1
2) make a Unit2 / Frame2
a) add Memo1
b) align Memo1, alClient
Look at Project/Options/Forms and move Frame2 to
Available section (if it's not moved automatically).
--- Unit1.cpp ---
#include "Unit2.h" // Because of Frame2
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
Frame2 = new TFrame2 ( this );
}
__fastcall TForm1::~TForm1()
{
delete Frame2;
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Frame2->Parent = Panel1;
}
--- Unit1.h ---
// added...
__fastcall ~TForm1();
--- Unit2.cpp & Unit2.h ---
// no code, just the design-time changes
--
Best regards,
Vladimir Stefanovic
|
|
|
| Back to top |
|
 |
Vladimir Stefanovic Guest
|
Posted: Fri Mar 25, 2005 3:04 pm Post subject: Re: Using Frames |
|
|
| Quote: | I tried it, but must be missing something since it didn't work.
|
What is the actual problem? Was the Frame2 invisible after
'Frame2->Parent = Panel8' ?
| Quote: | I created Frame2 and it is listed as available in Project options.
|
Yes, that's the correct place if you create the Frame by yourself
at run-time.
| Quote: | I also made sure that it's visible property is set to true.
....ButtonClick(TObject *Sender)
{
Frame2->Parent = Panel8;
Panel8->Visible = true;
|
This code looks fine to me.
Have you created your Frame2 at run-time, something
like this:
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
Frame2 = new TFrame2 ( this );
}
__fastcall TForm1::~TForm1()
{
delete Frame2;
}
You can place that code in the main form, or in the form
where you Button (to show it) resides.
I just tested the example I have shown you before and it's
working fine. Maybe you should compare the properties of
the blank TFrame and the properties of your master TFrame,
to see if there is something unusual setted in your frame.
--
Best regards,
Vladimir Stefanovic
|
|
| Back to top |
|
 |
Shubha Ramani Guest
|
Posted: Sun Jun 19, 2005 3:23 am Post subject: Re: Using Frames |
|
|
Hello. This thread was exactly what I needed. No...I am not
the person who originated the thread back in March.
I just happened to be browsing for answers on the topic of
'using Frames', and I stumbled upon this very helpful thread.
I tried everything
you suggested Vladimir, but I had problems with the destructor.
When I added a destructor to my form.cpp code, I get the following error:
[C++ Error] timer.cpp(40):
E2171 Body has already been defined for function '_fastcall
TTimerForm::~TTimerForm()'
The code I added is as follows :
//---------------------------------------------------------------------------
__fastcall TTimerForm::TTimerForm(TComponent* Owner)
: TForm(Owner)
{
leaderBoard = new TFrame1(this);
lapLog = new TFrame2(this);
}
__fastcall TTimerForm::~TTimerForm()
{
delete Frame1;
delete Frame2;
}
I could not find another occurrence of the TTimerForm destructor anywhere
in the project.
Any clues ?
Thanks,
Shubha Ramani
"Vladimir Stefanovic" <antivari (AT) po (DOT) sbb.co.yu> wrote
| Quote: | I tried it, but must be missing something since it didn't work.
What is the actual problem? Was the Frame2 invisible after
'Frame2->Parent = Panel8' ?
I created Frame2 and it is listed as available in Project options.
Yes, that's the correct place if you create the Frame by yourself
at run-time.
I also made sure that it's visible property is set to true.
....ButtonClick(TObject *Sender)
{
Frame2->Parent = Panel8;
Panel8->Visible = true;
This code looks fine to me.
Have you created your Frame2 at run-time, something
like this:
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
Frame2 = new TFrame2 ( this );
}
__fastcall TForm1::~TForm1()
{
delete Frame2;
}
You can place that code in the main form, or in the form
where you Button (to show it) resides.
I just tested the example I have shown you before and it's
working fine. Maybe you should compare the properties of
the blank TFrame and the properties of your master TFrame,
to see if there is something unusual setted in your frame.
--
Best regards,
Vladimir Stefanovic
|
|
|
| Back to top |
|
 |
Paul Embleton Guest
|
Posted: Tue Jun 21, 2005 9:20 am Post subject: Re: Using Frames |
|
|
"Shubha Ramani" <shubharamani (AT) gmail (DOT) com> wrote in news:42b4e51f$1
@newsgroups.borland.com:
| Quote: | Body has already been defined for function
|
I get this if I forget to declare the destructor in the header file. A
default destructor is created if you don't declare one.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|