Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

RegisterPropertyEditor bug??

Posted on 1998-11-09
9
Medium Priority
?
789 Views
Last Modified: 2012-06-27
Delphi's RegisterPropertyEditor procedure has the following declaration:

procedure RegisterPropertyEditor(PropertyType: PTypeInfo; ComponentClass: TClass; const PropertyName: string; EditorClass: TPropertyEditorClass);

The help file says the following: "Set the PropertyName parameter to restrict the property editor to properties with a specific name as well as the specified property type."

I would like to override the TStrings property editor, but ONLY for properties with a "specific name" (as the help file says) e.g. Address.  Thus for ANY component with a TStrings-derived property called "Address" it must use my property editor, but for all other TStrings-derived properties (e.g. TMemo's "Lines" property) Delphi must use the original property editor.

The problem I'm having is that Delphi uses my editor for all TStrings properties (e.g. TMemo's "Lines" property), instead of only for properties called "Address".

This is what my original code looked like:

RegisterPropertyEditor(TypeInfo(TStrings), nil, 'Address', TAddressPropEd);

The way I got around this problem is to declare my own class that is derived from TStrings:
type
  TAddressStrings = class(TStringList);

RegisterPropertyEditor(TypeInfo(TAddressStrings), nil, 'Address', TAddressPropEd);

The above code works, but I don't understand why it's necessary to derive my own class (if the help file is correct).
(I've tried this in D3 and D4, and both give the same result.)

Thanks,
JB
0
Comment
Question by:JimBob091197
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 8

Accepted Solution

by:
ZifNab earned 400 total points
ID: 1346301
JimBob,

I'm back for a short time, here's what I know :

Second parameter: is used to restrict a property editor's usage to a particular component type. If this parameter is set to NILL, the property editor is registered for ALL properties of the specified property type.
Third parameter: is valid ONLY if the second parameter is NOT nil. By specifying the name of the property, the property editor can be registered for a single property within a component, even though the component may contain additional properties of the same property type.

e.g. RegisterPropertyEditor(TypeInfo(string), TRkClockStatus, 'Format', TRkClockFormatProperty);

->the TRkClockFormatProperty editor is registered for only the format property of the RlClockStatus component. Other string properties defined in the RkClockStatus component are unaffected by this property editor.

More can be found in this Ray Konopka's book : Developing Custom Delphi3 components.

Regards, Zif.
0
 
LVL 5

Author Comment

by:JimBob091197
ID: 1346302
Thanks Zif.

Your comment "Third parameter: is valid ONLY if the second parameter is NOT nil" is what I was looking for.

The help file only says that you can set 3rd parameter (PropertyName) to "the property editor to properties with a specific name as well as the specified property type."

Note that "property type" is the 1st parameter, and the help file says nothing about what happens to the 3rd parameter (PropertyName) if the 2nd parameter (ComponentClass) is nil.

I figured this must be the case, else a bug, but thanks for clearing it up for me.

Cheers,
Dave
0
 
LVL 5

Author Comment

by:JimBob091197
ID: 1346303
Sorry, 2nd paragraph above should read:

The help file only says that you can set 3rd parameter (PropertyName) to "RESTRICT the property editor to properties with a specific name as well as the specified property type."

-Dave

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 8

Expert Comment

by:ZifNab
ID: 1346304
Glad I could be of assitance. JB, seeing your q'ns : you must almost have finished a great new component package?
0
 
LVL 5

Author Comment

by:JimBob091197
ID: 1346305
Not component package, but app!  ;-)  I will keep you informed...  I want to have a web site finished for it by end of November.

-Dave

0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1346306
Hey Great! Let me know of it, surely!
0
 
LVL 5

Author Comment

by:JimBob091197
ID: 1346307
Will do!

(For a sneak-preview go to http://www.geocities.com/SiliconValley/Lakes/9940/)

-Dave

0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1346308
JB, woow. Nice! Now I understand why you were so silently!
0
 
LVL 5

Author Comment

by:JimBob091197
ID: 1346309
Glad you liked it.  I'll be sure to keep you up-to-date.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

598 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question