Board index » cppbuilder » How to derive from TFrame?

How to derive from TFrame?


2004-08-13 05:33:13 PM
cppbuilder86
Hi.
How to derive from TFrame?
I created a new frame TframeYearlyPage, which by default derives from TFrame. But I want to create other classes like TframeTransactionPage and add a virtual functions in class TFrame, which the derived classes will override. But I can't change class TFrame.
So I created a new unit, and created a class TframePage derived from TFrame, and added the pure virtual functions in that class.
Then I changed my class TframeYearlyPage, which was derived from TFrame, to derive instead from TframePage.
Then compile and link the entire program. Then open TframeYearlyPage in the IDE, in order to see what it looks like. But I get an error message: "Error reading frameYearlyPage->TabOrder: Property TabOrder does not exist. Ignore the error and continue?".
It seems the problem comes from silently changing the base class of TframeYearlyPage from TFrame to TframePage.
So how to derive from TFrame in order to add new functions (both virtual and non-virtual)?
Here are my classes:
// common.h ==>
class TframePage : public TFrame
{
public:
__fastcall TframePage(TComponent* Owner);
void Clear();
private: // pure virtual functions
...
};
// YearlyPage.h ==>
class TframeYearlyPage : public TframePage
{
__published: // IDE-managed Components
TAdvStringGrid *Grid;
TPanel *panelItem;
...
public: // User declarations
__fastcall TframeYearlyPage(TComponent* Owner);
private: // virtual overrides
...
private: // User declarations
};
//---------------------------------------------------------------------------
extern PACKAGE TframeYearlyPage *frameYearlyPage;
//---------------------------------------------------------------------------
YearlyPage.dfm ==>
object frameYearlyPage: TframeYearlyPage
Left = 0
Top = 0
Width = 746
Height = 400
TabOrder = 0
object Grid: TAdvStringGrid
Thanks!
 
 

Re:How to derive from TFrame?

" XXXX@XXXXX.COM " < XXXX@XXXXX.COM >wrote:
Hi. Here's a repost, because I didn't format the text
correctly. Also, I have one more finding.
How to derive from TFrame?
I created a new frame TframeYearlyPage, which by default
derives from TFrame. But I want to create other classes like
TframeTransactionPage and add a virtual functions in class
TFrame, which the derived classes will override. But I can't
change class TFrame.
So I created a new unit, and created a class TframePage
derived from TFrame, and added the pure virtual functions
in that class.
Then I changed my class TframeYearlyPage, which was derived
from TFrame, to derive instead from TframePage.
Then compile and link the entire program.
The problem is that the the compiler thinks my class
TframeYearlyPage derives from TForm. In the object inspector
I see all properties pertinent to TForm, like Menu and
OldCreateOrder.
So now the question, is this a bug in Borland C++ Builder 6?
How to derive from TFrame (or whatever) in order to take advantage of virtual functions?
Thanks.
Please note, there is no file common.dfm to give the definition of TframgePage.
// common.h ==>
class TframePage : public TFrame
{
public:
__fastcall TframePage(TComponent* Owner);
void Clear();
private: // pure virtual functions
...
};
// YearlyPage.h ==>
class TframeYearlyPage : public TframePage
{
__published: // IDE-managed Components
TAdvStringGrid *Grid;
TPanel *panelItem;
...
public: // User declarations
__fastcall TframeYearlyPage(TComponent* Owner);
private: // virtual overrides
...
private: // User declarations
};
//-----------------------------------------------------------
extern PACKAGE TframeYearlyPage *frameYearlyPage;
//-----------------------------------------------------------
YearlyPage.dfm ==>
object frameYearlyPage: TframeYearlyPage
Left = 0
Top = 0
Width = 746
Height = 400
TabOrder = 0
object Grid: TAdvStringGrid
 

Re:How to derive from TFrame?

XXXX@XXXXX.COM wrote:
Quote
" XXXX@XXXXX.COM " < XXXX@XXXXX.COM >wrote:

Hi. Here's a repost, because I didn't format the text
correctly. Also, I have one more finding.

How to derive from TFrame?

I created a new frame TframeYearlyPage, which by default
derives from TFrame. But I want to create other classes like
TframeTransactionPage and add a virtual functions in class
TFrame, which the derived classes will override. But I can't
change class TFrame.

So I created a new unit, and created a class TframePage
derived from TFrame, and added the pure virtual functions
in that class.

Then I changed my class TframeYearlyPage, which was derived
from TFrame, to derive instead from TframePage.

Then compile and link the entire program.

The problem is that the the compiler thinks my class
TframeYearlyPage derives from TForm. In the object inspector
I see all properties pertinent to TForm, like Menu and
OldCreateOrder.

So now the question, is this a bug in Borland C++ Builder 6?
How to derive from TFrame (or whatever) in order to take advantage of virtual functions?

Thanks.

Please note, there is no file common.dfm to give the definition of TframgePage.

// common.h ==>
class TframePage : public TFrame
{
public:
__fastcall TframePage(TComponent* Owner);
void Clear();
private: // pure virtual functions
...
};

// YearlyPage.h ==>
class TframeYearlyPage : public TframePage
{
__published: // IDE-managed Components
TAdvStringGrid *Grid;
TPanel *panelItem;
...
public: // User declarations
__fastcall TframeYearlyPage(TComponent* Owner);
private: // virtual overrides
...
private: // User declarations
};
//-----------------------------------------------------------
extern PACKAGE TframeYearlyPage *frameYearlyPage;
//-----------------------------------------------------------

YearlyPage.dfm ==>
object frameYearlyPage: TframeYearlyPage
Left = 0
Top = 0
Width = 746
Height = 400
TabOrder = 0
object Grid: TAdvStringGrid


For my answer I'll give your project the name "Frame". After you create
the base class TframePage and sucessfully make the Frame project, go to
File->New->Other. There will be a tab named "Frame". Select the
"Frame" tab and the will an object of type TframePage on it. Select
that object and you will have a new object that is derived from
TframePage. Name the derived object TframeYearPage and you will have
what you want. You cannot directly change the base type of the object
as you were attempting to do.
HTH
Danzer
 

{smallsort}

Re:How to derive from TFrame?

Danzer < XXXX@XXXXX.COM >wrote:
Quote
XXXX@XXXXX.COM wrote:
>I created a new frame TframeYearlyPage, which by default
>derives from TFrame. But I want to create other classes like
>TframeTransactionPage and add a virtual functions in class
>TFrame, which the derived classes will override. But I can't
>change class TFrame.
For my answer I'll give your project the name "Frame". After you create
the base class TframePage and sucessfully make the Frame project, go to
File->New->Other. There will be a tab named "Frame". Select the
"Frame" tab and the will an object of type TframePage on it. Select
that object and you will have a new object that is derived from
TframePage. Name the derived object TframeYearPage and you will have
what you want. You cannot directly change the base type of the object
as you were attempting to do.
Thanks. I tried this the other day and it works! But what I did in my version of C++ Builder is create my FramePage from File ->New ->Frame and name the class TFramePage with the filename Page.cpp, then create a my FrameYearlyPage from File ->New ->Other / Application tab ->select FramePage and at this point Inherited radio bottom at the bottom of the dialog box is checked and the other radio buttons are grayed out and name the class to whatever and save it as whatever.
The .dfm file has the "inherited" keyword in the first line.