 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Edward Diener Guest
|
Posted: Sun Aug 17, 2003 11:47 pm Post subject: Creating property editors for native types broken in BCB6 |
|
|
Attempts to set up property editors for native types are completely broken
in BCB6. By native types I mean property editors for 'int', 'double' etc.
types in components. I will post a QC report on this, with attachment, but
first I want to post on the NGs so that if anyone has a workaround which
actually works, I can use that.
I have used a technique for getting the type of the native property, for the
first parameter of RegisterPropertyEditor, which has worked in BCB3, BCB4,
and BCB5 but no longer works in BCB6. The method I have used, from the BCB
Unleashed and Developer's Guide series of books from Sams, is to create a
C++ VCL class with a property of the needed type and get the typinfo
information from that. As an example, to get typeinfo information for a
'double' type I create, in header file DoublePropertyType.h:
#if !defined(DOUBLE_PROPERTY_TYPE_H)
#define DOUBLE_PROPERTY_TYPE_H
#include <SysUtils.hpp>
#include <Controls.hpp>
#include <Classes.hpp>
#include <Forms.hpp>
class PACKAGE DoublePropertyType : public System::TObject
{
__published:
__property double DoubleProperty = {read = DDummy, write = DDummy };
private:
inline __fastcall DoublePropertyType() {}
double DDummy;
};
#endif
then I use in my RegisterPropertyEditor code:
Typinfo::TTypeInfo * dptype(__typeinfo(DoublePropertyType));
Typinfo::TPropInfo * dpprop(Typinfo::GetPropInfo(dptype,"DoubleProperty"));
Typinfo::TTypeInfo ** dpft(dpprop -> PropType);
and use *dpft as the first parameter to RegisterPropertyEditor. When I step
through such code, everything is working properly but even though I register
a property editor for a particular 'double' property in another component
this way, the property editor never gets called.
Has any other C++ Builder programmer attempted to create a property editor
in BCB6 for a native C++ type ? If so I would appreciate knowing how to do
this since BCB6 is broke as far as I can test. I need to create property
editors for specific 'double', 'int', and '__int64' types in some components
for BCB6 and it is always failing to do so. The exact same code, as
illustrated by the technique above, works fine for BCB3, BCB4, and BCB5.
I will gladly post a QC report on this which easily shows the problem in an
attachment but I would really like someone to confirm or deny this broken
part of BCB6 so I can find a solution. Posting reports on QC only to have
them ignored, by others and Borland, is not my idea of a way to solve my
programming problems. Thanks !
|
|
| Back to top |
|
 |
Jeff Overcash (TeamB) Guest
|
Posted: Mon Aug 18, 2003 2:20 am Post subject: Re: Creating property editors for native types broken in BCB |
|
|
This hack doesn't work any more and frankly was always a hack and should have
never worked. This is the correct way to get at a native type's type info and
works for all versions of BCB.
TPropInfo *PropInfo = ::GetPropInfo(__typeinfo(TMyComponent), "FileName");
RegisterPropertyEditor(*PropInfo->PropType, __classid(TMyComponent),
"FileName", __classid(TMyFileNameEditor));
Edward Diener wrote:
| Quote: |
Attempts to set up property editors for native types are completely broken
in BCB6. By native types I mean property editors for 'int', 'double' etc.
types in components. I will post a QC report on this, with attachment, but
first I want to post on the NGs so that if anyone has a workaround which
actually works, I can use that.
I have used a technique for getting the type of the native property, for the
first parameter of RegisterPropertyEditor, which has worked in BCB3, BCB4,
and BCB5 but no longer works in BCB6. The method I have used, from the BCB
Unleashed and Developer's Guide series of books from Sams, is to create a
C++ VCL class with a property of the needed type and get the typinfo
information from that. As an example, to get typeinfo information for a
'double' type I create, in header file DoublePropertyType.h:
#if !defined(DOUBLE_PROPERTY_TYPE_H)
#define DOUBLE_PROPERTY_TYPE_H
#include <SysUtils.hpp
#include
#include
#include
class PACKAGE DoublePropertyType : public System::TObject
{
__published:
__property double DoubleProperty = {read = DDummy, write = DDummy };
private:
inline __fastcall DoublePropertyType() {}
double DDummy;
};
#endif
then I use in my RegisterPropertyEditor code:
Typinfo::TTypeInfo * dptype(__typeinfo(DoublePropertyType));
Typinfo::TPropInfo * dpprop(Typinfo::GetPropInfo(dptype,"DoubleProperty"));
Typinfo::TTypeInfo ** dpft(dpprop -> PropType);
and use *dpft as the first parameter to RegisterPropertyEditor. When I step
through such code, everything is working properly but even though I register
a property editor for a particular 'double' property in another component
this way, the property editor never gets called.
Has any other C++ Builder programmer attempted to create a property editor
in BCB6 for a native C++ type ? If so I would appreciate knowing how to do
this since BCB6 is broke as far as I can test. I need to create property
editors for specific 'double', 'int', and '__int64' types in some components
for BCB6 and it is always failing to do so. The exact same code, as
illustrated by the technique above, works fine for BCB3, BCB4, and BCB5.
I will gladly post a QC report on this which easily shows the problem in an
attachment but I would really like someone to confirm or deny this broken
part of BCB6 so I can find a solution. Posting reports on QC only to have
them ignored, by others and Borland, is not my idea of a way to solve my
programming problems. Thanks !
|
--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
If there is somebody up there could they throw me down a line. Just a
little helping hand just a little understanding. Just some answers to the
questions that surround me now. If there's somebody up there could
they throw me down a line. (Fish)
|
|
| Back to top |
|
 |
Edward Diener Guest
|
Posted: Mon Aug 18, 2003 3:01 am Post subject: Re: Creating property editors for native types broken in BCB |
|
|
Jeff Overcash (TeamB) wrote:
| Quote: | This hack doesn't work any more and frankly was always a hack and
should have never worked. This is the correct way to get at a native
type's type info and works for all versions of BCB.
TPropInfo *PropInfo = ::GetPropInfo(__typeinfo(TMyComponent),
"FileName"); RegisterPropertyEditor(*PropInfo->PropType,
__classid(TMyComponent), "FileName", __classid(TMyFileNameEditor));
|
Thank you very much, Jeff. I never realized that one could use __typeinfo on
the actual component and property for which one is attempting to register a
property editor. According to the information in the Sams C++ Builder 5
Developer's Guide, doing the above only works for cases of a published
property already in use by the VCL. That is why I thought it could not be
done and used the "hack" they give in the book instead reproduced in my
original post. What you are saying is that the info in the book is wrong, or
that the component is considered "in use" as soon as I have registered it.
But I truly don't see the difference, other than redundancy, of doing the
above as opposed to creating a class to hold a property with a given type
and using that property instead. In both cases I have a property of a given
type which I use to get my first PTypeInfo parameter. Why should the above
work using the actual property when my "hack" does not, when the type of
each property is the same ? I am very curious about that, but I will still
try your technique above to fix my problem.
| Quote: |
Edward Diener wrote:
Attempts to set up property editors for native types are completely
broken in BCB6. By native types I mean property editors for 'int',
'double' etc. types in components. I will post a QC report on this,
with attachment, but first I want to post on the NGs so that if
anyone has a workaround which actually works, I can use that.
I have used a technique for getting the type of the native property,
for the first parameter of RegisterPropertyEditor, which has worked
in BCB3, BCB4, and BCB5 but no longer works in BCB6. The method I
have used, from the BCB Unleashed and Developer's Guide series of
books from Sams, is to create a C++ VCL class with a property of the
needed type and get the typinfo information from that. As an
example, to get typeinfo information for a 'double' type I create,
in header file DoublePropertyType.h:
#if !defined(DOUBLE_PROPERTY_TYPE_H)
#define DOUBLE_PROPERTY_TYPE_H
#include <SysUtils.hpp
#include
#include
#include
class PACKAGE DoublePropertyType : public System::TObject
{
__published:
__property double DoubleProperty = {read = DDummy, write = DDummy };
private:
inline __fastcall DoublePropertyType() {}
double DDummy;
};
#endif
then I use in my RegisterPropertyEditor code:
Typinfo::TTypeInfo * dptype(__typeinfo(DoublePropertyType));
Typinfo::TPropInfo *
dpprop(Typinfo::GetPropInfo(dptype,"DoubleProperty"));
Typinfo::TTypeInfo ** dpft(dpprop -> PropType);
and use *dpft as the first parameter to RegisterPropertyEditor. When
I step through such code, everything is working properly but even
though I register a property editor for a particular 'double'
property in another component this way, the property editor never
gets called.
Has any other C++ Builder programmer attempted to create a property
editor in BCB6 for a native C++ type ? If so I would appreciate
knowing how to do this since BCB6 is broke as far as I can test. I
need to create property editors for specific 'double', 'int', and
'__int64' types in some components for BCB6 and it is always failing
to do so. The exact same code, as illustrated by the technique
above, works fine for BCB3, BCB4, and BCB5.
I will gladly post a QC report on this which easily shows the
problem in an attachment but I would really like someone to confirm
or deny this broken part of BCB6 so I can find a solution. Posting
reports on QC only to have them ignored, by others and Borland, is
not my idea of a way to solve my programming problems. Thanks !
|
|
|
| Back to top |
|
 |
Edward Diener Guest
|
Posted: Mon Aug 18, 2003 4:34 pm Post subject: Re: Creating property editors for native types broken in BCB |
|
|
Jamie wrote:
| Quote: | Jeff, this is well known also but to the best of my knowledge also
does not work for builtin types. Have you example cope that registers
a property editor for type unsigned or any other built-in type? I
would love to hear of a real working example....
|
Jeff's suggestion for built-in types works fine in BCB6.
|
|
| Back to top |
|
 |
Edward Diener Guest
|
Posted: Mon Aug 18, 2003 4:35 pm Post subject: Re: Creating property editors for native types broken in BCB |
|
|
Jeff Overcash (TeamB) wrote:
| Quote: | This hack doesn't work any more and frankly was always a hack and
should have never worked. This is the correct way to get at a native
type's type info and works for all versions of BCB.
TPropInfo *PropInfo = ::GetPropInfo(__typeinfo(TMyComponent),
"FileName"); RegisterPropertyEditor(*PropInfo->PropType,
__classid(TMyComponent), "FileName", __classid(TMyFileNameEditor));
|
Thanks ! That works fine in BCB6. I wonder why all the book authors have
this wrong.
|
|
| Back to top |
|
 |
Jamie Guest
|
Posted: Mon Aug 18, 2003 5:22 pm Post subject: Re: Creating property editors for native types broken in BCB |
|
|
"Edward Diener" <eddielee (AT) tropicsoft (DOT) com> wrote
| Quote: | Jeff Overcash (TeamB) wrote:
This hack doesn't work any more and frankly was always a hack and
should have never worked. This is the correct way to get at a native
type's type info and works for all versions of BCB.
TPropInfo *PropInfo = ::GetPropInfo(__typeinfo(TMyComponent),
"FileName"); RegisterPropertyEditor(*PropInfo->PropType,
__classid(TMyComponent), "FileName", __classid(TMyFileNameEditor));
Thanks ! That works fine in BCB6. I wonder why all the book authors have
this wrong.
|
Because when BCB 6 was first out in beta it did not work AFAIR, but I could
be wrong. Anyway, that is why I did not update the material from the BCB 5
book. It seems I can go back and have another look...
Thanks
Jamie
|
|
| Back to top |
|
 |
Edward Diener Guest
|
Posted: Mon Aug 18, 2003 5:52 pm Post subject: Re: Creating property editors for native types broken in BCB |
|
|
Jamie wrote:
| Quote: | "Edward Diener" <eddielee (AT) tropicsoft (DOT) com> wrote in message
news:3f41003c (AT) newsgroups (DOT) borland.com...
Jeff Overcash (TeamB) wrote:
This hack doesn't work any more and frankly was always a hack and
should have never worked. This is the correct way to get at a
native type's type info and works for all versions of BCB.
TPropInfo *PropInfo = ::GetPropInfo(__typeinfo(TMyComponent),
"FileName"); RegisterPropertyEditor(*PropInfo->PropType,
__classid(TMyComponent), "FileName", __classid(TMyFileNameEditor));
Thanks ! That works fine in BCB6. I wonder why all the book authors
have this wrong.
Because when BCB 6 was first out in beta it did not work AFAIR, but I
could be wrong. Anyway, that is why I did not update the material
from the BCB 5 book. It seems I can go back and have another look...
|
I am using the BCB5 book and the chapter which you, if you are Jamie Allsop,
wrote on "Creating Property and Component Editors" is wonderful. Many thanks
!
I haven't tried the technique mentioned by Jeff for BCB3, BCB4, and BCB5
since the technique which you wrote on page 430, "Obtaining a TTypeInfo *
(PTypeInfo) from an Existing Property and Class for a Non-VCL Type", works
fine with those releases when creating a class which has a property of the
correct type . It did not work for BCB6, which is why the original post.
If indeed Jeff's technique, of using the actual component and property for
which one is registering the property editor to get the PTypeInfo, has
always worked, it is a bit amazing that no one realized that before. You
wrote on page 432 that your method "relies on there being a published
property of the desired type already in use by the VCL." The assumption was
evidently that one could not use the actual type of the property for which
one is registering the property editor. Perhaps that assumption was always
wrong because as soon as a component itself is registered, it is "already in
use by the VCL". I don't know but I am glad I have this working now for
BCB6.
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Mon Aug 18, 2003 8:58 pm Post subject: Re: Creating property editors for native types broken in BCB |
|
|
"Edward Diener" <eddielee (AT) tropicsoft (DOT) com> wrote
| Quote: | If indeed Jeff's technique, of using the actual component
and property for which one is registering the property
editor to get the PTypeInfo, has always worked, it is a
bit amazing that no one realized that before.
|
Yes, it has always worked, in all versions of Builder. Jeff has been
providing this technique in replies to postings for years. I can personally
vouche for the technique as I use it in one of my own components, which
registers 6 different custom property editors for itself. My packages share
a single codebase under all versions of Builder.
Gambit
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ([url]http://www.grisoft.com)[/url].
Version: 6.0.510 / Virus Database: 307 - Release Date: 8/14/03
|
|
| Back to top |
|
 |
Edward Diener Guest
|
Posted: Mon Aug 18, 2003 11:22 pm Post subject: Re: Creating property editors for native types broken in BCB |
|
|
Remy Lebeau (TeamB) wrote:
| Quote: | "Edward Diener" <eddielee (AT) tropicsoft (DOT) com> wrote in message
news:3f411275$1 (AT) newsgroups (DOT) borland.com...
If indeed Jeff's technique, of using the actual component
and property for which one is registering the property
editor to get the PTypeInfo, has always worked, it is a
bit amazing that no one realized that before.
Yes, it has always worked, in all versions of Builder. Jeff has been
providing this technique in replies to postings for years. I can
personally vouche for the technique as I use it in one of my own
components, which registers 6 different custom property editors for
itself. My packages share a single codebase under all versions of
Builder.
|
Not to take anything away from the fine past work of Mr. Calvert,
Mr.Reisdorph, and Mr. Allsop, but some of these book authors should have
been listening also. I will admit that I followed the Sams series of books
on this and never realized that Mr. Overcash's method works. It is, of
course, much easier and more transparent than any other method. It would of
course be rewarding if Mr. Overcash's excellent solution were explained in
the official Borland's own developer guide also, whose explanation never
covers non-VCL types.
|
|
| 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
|
|