Board index » cppbuilder » Add a new property for a form?

Add a new property for a form?

Hi all !

I have a strange problem.
I woiuld like to assign a new property to a form
like this :

#pragma option push -b-
enum Tnewpropvalues {pZero,pOne,PTwo};
#pragma option pop

class TForm1 : public TForm
{
__published:
        __property Tnewpropvalues newprop  = { read=Fnewprop,
write=Fnewprop, default=pOne }; // IDE-managed Components
private:
        Tnewpropvalues Fnewprop;        // User declarations
public:         // User declarations
        __fastcall TForm1(TComponent* Owner);

Quote
};

extern PACKAGE TForm1 *Form1;

I did it with the property wizard of BCB, but when I try
to compile, I got an error message before the real compilation
began : "Error in module Unit1 : Incorrect field declaration in class
Tform1"

Sometimes it comes when I want to only save...

I really don't know why it happen, the help is not too informative :-(.

The environment is : BCB5 Enterpirse, WinNT4 Sp6, PIII 866, 256MB RAM.

If someone has any hint, I would appreciete !!!!

Thanks in advance !

BR.
   Zoltan, Nagy /Schwarzy/

 

Re:Add a new property for a form?


On Sun, 16 Sep 2001 00:23:45 +0200, Nagy Zolt?n <schwa...@mailbox.hu>
wrote:

Quote
>I really don't know why it happen, the help is not too informative :-(.

Borland's help says:

"Note that this first section of the form's class declaration is
reserved for use by the form designer. To declare your own fields and
methods, place them in a separate public, private, or protected
section."

Your code should be changed to somthing like this:

should be changed to

class TForm1 : public TForm
{
__published:
        // this part is reserved for use by designer
private:
        Tnewpropvalues Fnewprop;        
public:        
        __fastcall TForm1(TComponent* Owner);

// HERE YOU MAY DESCRIBE YOUR OWN PROPERTIES
__published:
        __property Tnewpropvalues newprop  = { read=Fnewprop,
write=Fnewprop, default=pOne };

Quote
};

Re:Add a new property for a form?


Hello Nagy,

"Nagy Zoltn" <schwa...@mailbox.hu> schreef in bericht
news:3BA3D4F1.EB73A737@mailbox.hu...

Quote
> Hi all !

[snip]

Quote
> class TForm1 : public TForm
> {
> __published:
>         __property Tnewpropvalues newprop  = { read=Fnewprop,
> write=Fnewprop, default=pOne }; // IDE-managed Components
> private:
>         Tnewpropvalues Fnewprop; // User declarations
> public: // User declarations
>         __fastcall TForm1(TComponent* Owner);
> };

> extern PACKAGE TForm1 *Form1;

Hmm, first of all never put things in the top __published section by hand,
or let the ClassExplorer wizard do that<g>, since those entries are
exclusive handled by the IDE only.
As for __property's, afaik you shouldn't use __published __property in a
runtime situation. Those are only effective if you create and/or derive a
new component.
If you place your new property in the public section of your TForm1 class it
will work as expected...

Quote
> Thanks in advance !

Hope this helps...;-))

Quote
>    Zoltan, Nagy /Schwarzy/

--
Greetings from overcast Amsterdam

         Jan

email: bijs...@worldonline.nl
http://home.worldonline.nl/~bijster

Other Threads