JimBob091197
asked on
RegisterPropertyEditor bug??
Delphi's RegisterPropertyEditor procedure has the following declaration:
procedure RegisterPropertyEditor(Pro pertyType: 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(Typ eInfo(TStr ings), 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(Typ eInfo(TAdd ressString s), 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
procedure RegisterPropertyEditor(Pro
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(Typ
The way I got around this problem is to declare my own class that is derived from TStrings:
type
TAddressStrings = class(TStringList);
RegisterPropertyEditor(Typ
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
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
Glad I could be of assitance. JB, seeing your q'ns : you must almost have finished a great new component package?
ASKER
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
-Dave
Hey Great! Let me know of it, surely!
ASKER
JB, woow. Nice! Now I understand why you were so silently!
ASKER
Glad you liked it. I'll be sure to keep you up-to-date.
ASKER
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