BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

My own class type of Property

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Development)
View previous topic :: View next topic  
Author Message
Jet
Guest





PostPosted: Fri Aug 13, 2004 3:51 am    Post subject: My own class type of Property Reply with quote




hi again folks! i have another problem, and hope that you can
help me out, like you always do. =)
this is related to my previous post, about events with
parameters.
I wanted to use Valedit::TItemProp for my customized
ListView to use the properties of the ValueListEditor's
ItemProps.
So I declared my own
__property Valedit::TItemProp ColumnProps[int] =
{read = GetColumnProps, write = SetColumnProps};

but it says "VCL-style classes must be constructed using the
operator new."

so I just decided to have my own class,
class TColumnProp {
// members
};

then use it as a property :

__property TColumnProp ColumnProps[int] = { // read and write};

but now the error is "Not an allowed type".

Am I allowed to use my own class as a type for a property?

Or do you have any other suggestions on how I can implement
TValueListEditor's ItemProps?
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Fri Aug 13, 2004 6:19 am    Post subject: Re: My own class type of Property Reply with quote




"Jet" <jettosan (AT) yahoo (DOT) com> wrote


Quote:
__property Valedit::TItemProp ColumnProps[int] =
{read = GetColumnProps, write = SetColumnProps};

but it says "VCL-style classes must be constructed using the
operator new."

You need to declare your property to use pointers:

// notice the asteriks

Valedit::TItemProp* __fastcall GetColumnProps(int index);
void __fastcall SetColumnProps(int index, Valedit::TItemProp *value);

__property Valedit::TItemProp* ColumnProps[int] = {read=GetColumnProps,
write=SetColumnProps};


Gambit



Back to top
Jet
Guest





PostPosted: Fri Aug 13, 2004 8:11 am    Post subject: Re: My own class type of Property Reply with quote




"Remy Lebeau (TeamB)" <gambit47.no.spam (AT) no (DOT) spam.yahoo.com> wrote:
Quote:
You need to declare your property to use pointers:

// notice the asteriks


Thanks, but what if I want to use
__property TColumnProp ColumnProps[int] =
{read = GetColumnProps, write = SetColumnProps};

class TColumnProp {
// members
};

instead? Because I want to create an EditStyle with a different
enum set.

Can't I use a user-defined class as a property type?

Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Fri Aug 13, 2004 5:26 pm    Post subject: Re: My own class type of Property Reply with quote


"Jet" <jettosan (AT) yahoo (DOT) com> wrote


Quote:
Thanks, but what if I want to use

You should still be using pointers anyway, it is more efficient than
creating temporary instances every time your property is accessed.

Quote:
Can't I use a user-defined class as a property type?

Of course you can. But that is not the issue here. Your original code
could not use Valedit::TItemProp because you were not using pointers. VCL
objects cannot be instantiated on the stack, they must always be on the
heap, thus the need for pointers. Once you get that working, it is simple
to adapt the code to use a custom class instead of Valedit::TItemProp, but I
still recommend the use of pointers for the property.


Gambit



Back to top
Jet
Guest





PostPosted: Sun Aug 15, 2004 3:05 am    Post subject: Re: My own class type of Property Reply with quote


"Remy Lebeau (TeamB)" <gambit47.no.spam (AT) no (DOT) spam.yahoo.com> wrote:
Quote:
You should still be using pointers anyway, it is more efficient than
creating temporary instances every time your property is accessed.
--)) Ok, i'll remember that. Thanks.


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Development) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.