Board index » cppbuilder » Creating new form properties

Creating new form properties

Hello,

I have a question regarding forms. I would like to create a form class i.e
decendant from Tform or TcustomForm. There i would like to place several
__published properties, so when create a new form from the template, then i
can see my new form properties in the Object Inspector together with the
other standard form properties. My question is HOW?

I'am using C++ Builder v4.

Best regards,

Jakob Petersen
Microhouse

 

Re:Creating new form properties


You need to register the form.  The easiest way is to

1.  Add the form to the Object repository.
2.  Add the form to a package and in the package add a Register procedure like
you would for a component.
3.  In the Register procedure call RegisterCustomModule to register the form.
4.  Install the package.

When you create a decendant form make sure that you inherit from it.  You should
see the extra properties.

Quote
Jakob Petersen wrote:

> Hello,

> I have a question regarding forms. I would like to create a form class i.e
> decendant from Tform or TcustomForm. There i would like to place several
> __published properties, so when create a new form from the template, then i
> can see my new form properties in the Object Inspector together with the
> other standard form properties. My question is HOW?

> I'am using C++ Builder v4.

> Best regards,

> Jakob Petersen
> Microhouse

--
Jeff Overcash (TeamB)
      (Please do not email me directly unless  asked. Thank You)
Mild mannered supermen are held in kryptonite, and the wise and foolish
{*word*269}s giggle with their bodies glowing bright.  Through the door a harvest
feast is lit by candlelight; it's the bottom of the staircase that spirals out
of sight.
  (new classic Genesis) Carpet Crawlers 1999
--

Re:Creating new form properties


Hi,

Thanks for your help. I have a little problem though. Where is the function
documented? I can see that it takes 2 TMetaClasse's as parameters.

Best Regards,

Jakob Petersen
Microhouse

Jakob Petersen skrev i meddelelsen <7sptjp$r...@forums.borland.com>...

Quote
>Hello,

>I have a question regarding forms. I would like to create a form class i.e
>decendant from Tform or TcustomForm. There i would like to place several
>__published properties, so when create a new form from the template, then i
>can see my new form properties in the Object Inspector together with the
>other standard form properties. My question is HOW?

>I'am using C++ Builder v4.

>Best regards,

>Jakob Petersen
>Microhouse

Re:Creating new form properties


Hi,

I really cant make it work. Maybe im doing something wrong. I assumed that
the RegisterCustomModule function should replace the normal
RegisterComponents function.

MhForm.CPP:

#include "MhForm.h"
#pragma package(smart_init)
#pragma resource "*.dfm"
TMhForm *MhForm;
//--------------------------------------------------------------------------
-
// ValidCtrCheck is used to assure that the components created do not have
// any pure virtual functions.
//

static inline void ValidCtrCheck(TMhForm *)
{
        new TMhForm(NULL);

Quote
}

//--------------------------------------------------------------------------
-
__fastcall TMhForm::TMhForm(TComponent* Owner)
        : TForm(Owner)
{
Quote
}

//--------------------------------------------------------------------------
-
namespace Mhform
{
        void __fastcall PACKAGE Register()
        {
                 //TComponentClass classes[1] = {__classid(TMhForm)};
                 // RegisterComponents("Microhouse", classes, 0);
                 RegisterCustomModule(__classid(TForm),__classid(TMhForm));
        }

Quote
}

MhForm.h:

class PACKAGE TMhForm : public TForm
{
private:
 int FTest;
protected:
public:
        __fastcall TMhForm(TComponent* Owner);
__published:
 __property int MhTest = {read=FTest, write=FTest};

Quote
};

extern PACKAGE TMhForm *MhForm;

MhForm.DFM:

object MhForm: TMhForm
  Left = 261
  Top = 202
  Width = 696
  Height = 480
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
end

Best regards,

Jakob Petersen
Microhouse

Re:Creating new form properties


Hi, Jakob!

If you wish to create a new form class from TCustomForm, you must also
write an expert. I recommend Delphi Developer's Guide as a good
reference for this process.

Alternatively, create a normal form, add components to it, add
properties to the published section (they will not show up yet), put the
form in the repository, and then inherit it from the repository. The
derived class should show those new properties (I have not done this,
but I have seen it posted that this works).

I hope this helps.

------
Mark Cashman (TeamB - C++ Builder), creator of The Temp{*word*203}Doorway at
http://www.temporaldoorway.com
- Original digital art, writing, music and more -
C++ Builder / JBuilder Tips and The C++ Builder Programmer's Webring
(Join us!)
http://www.temporaldoorway.com/programming/index.htm
------

Re:Creating new form properties


Hi Mark,

Thank you for your answer. I have looked in the delphi developers guide, and
i cant find anything about experts. Your alternative doesnt work. I can
create the form files CPP,H and DFM file and add it to the repository, and
then derive it, but the published property i have defined in the h file,
doesnt show. I really would like to know why the function
RegisterCustomModule is not documentet and where i can get a fully helpful
description on how to do this form class/component. I have used 3 days on
this issue, and im getting tired. I have placed a payed support question at
Borland Support, but i havent heard from them in 4 days. I'm DESPERATE!!

Please help,

Best regards,

Jakob Petersen
Microhouse

Mark Cashman (TeamB BCB) skrev i meddelelsen
<37F391F9.38694...@ix.netcom.com>...

Quote
>Hi, Jakob!

>If you wish to create a new form class from TCustomForm, you must also
>write an expert. I recommend Delphi Developer's Guide as a good
>reference for this process.

>Alternatively, create a normal form, add components to it, add
>properties to the published section (they will not show up yet), put the
>form in the repository, and then inherit it from the repository. The
>derived class should show those new properties (I have not done this,
>but I have seen it posted that this works).

>I hope this helps.

>------
>Mark Cashman (TeamB - C++ Builder), creator of The Temp{*word*203}Doorway at
>http://www.temporaldoorway.com
>- Original digital art, writing, music and more -
>C++ Builder / JBuilder Tips and The C++ Builder Programmer's Webring
>(Join us!)
>http://www.temporaldoorway.com/programming/index.htm
>------

Re:Creating new form properties


Hi, Jakob!

I apologize, I meant to write "Delphi Developer's Handbook" Cantu et al.
You can get it from Amazon.com if from nowhere local.

Unfortunately, this is a very advanced topic and I am not sure what
Borland will be able to do for you, since it sort of falls into the
"consulting" class of services. It would be wise in the meantime to
visit the .vcl.components.writing group to ask questions there about
experts and extending custom forms. There may also be some good Delphi
newsgroups on the subject.

The only documentation for the advanced features of BCB are in the
header files (.hpp) and in third party books (mostly Delphi). Relatively
few people use them, and the documentation already fielded is huge, so
Borland hasn't done a lot of work in that area. Hang in there, though,
the information exists.

In the meantime, if you are up against the wall, define a component to
hold the desired properties, and add it to the form. It's essentially
the same thing. You can even define public properties which get / set
values in the component for programmatic use. I've used this technique
many times.

Hope this helps.

------
Mark Cashman (TeamB - C++ Builder), creator of The Temp{*word*203}Doorway at
http://www.temporaldoorway.com
- Original digital art, writing, music and more -
C++ Builder / JBuilder Tips and The C++ Builder Programmer's Webring
(Join us!)
http://www.temporaldoorway.com/programming/index.htm
------

Re:Creating new form properties


Hi Mark,

Thank you for your direct and quick answer, I will get that book right away.
I am fortunately already making a non visual component to put on the form
(almost done).

Best regards,

Jakob Petersen
Microhouse

Mark Cashman (TeamB BCB) skrev i meddelelsen
<37F56C50.143E7...@ix.netcom.com>...

Quote
>Hi, Jakob!

>I apologize, I meant to write "Delphi Developer's Handbook" Cantu et al.
>You can get it from Amazon.com if from nowhere local.

>Unfortunately, this is a very advanced topic and I am not sure what
>Borland will be able to do for you, since it sort of falls into the
>"consulting" class of services. It would be wise in the meantime to
>visit the .vcl.components.writing group to ask questions there about
>experts and extending custom forms. There may also be some good Delphi
>newsgroups on the subject.

>The only documentation for the advanced features of BCB are in the
>header files (.hpp) and in third party books (mostly Delphi). Relatively
>few people use them, and the documentation already fielded is huge, so
>Borland hasn't done a lot of work in that area. Hang in there, though,
>the information exists.

>In the meantime, if you are up against the wall, define a component to
>hold the desired properties, and add it to the form. It's essentially
>the same thing. You can even define public properties which get / set
>values in the component for programmatic use. I've used this technique
>many times.

>Hope this helps.

>------
>Mark Cashman (TeamB - C++ Builder), creator of The Temp{*word*203}Doorway at
>http://www.temporaldoorway.com
>- Original digital art, writing, music and more -
>C++ Builder / JBuilder Tips and The C++ Builder Programmer's Webring
>(Join us!)
>http://www.temporaldoorway.com/programming/index.htm
>------

Other Threads