Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 2005.12.04;
Скачать: [xml.tar.bz2];

Вниз

Спрятать свойства наследуемого компонента   Найти похожие ветки 

 
den303 ©   (2005-11-02 17:20) [0]

Доброго времени суток!
Каким образом можно спрятать некоторые свойства компонента при наследовании и можно ли вообще? Понадобилось срочно написать компонент, наследуемый от TChart, с заранее заданными свойствами. Причём из видимых свойств должны остаться только несколько.


 
den303 ©   (2005-11-02 19:18) [1]

Удалено модератором
Примечание: Создание пустых сообщений


 
umbra ©   (2005-11-02 19:22) [2]

уменьшить область видимости свойств и методов нельзя.


 
den303 ©   (2005-11-02 23:05) [3]

Есть ли какой-нибудь способ создания компонента, аналогичного TChart с отображением только части его свойств и методов? Возможно, не через наследование? А как?


 
den303 ©   (2005-11-03 00:28) [4]

Вот что нарыл Яндексом:
К сожалению уменьшить область видимости св-ва в Delphi нельзя, однако пpосто скpыть свойство из Object Inspector-а помогает RegisterPropertyEditor(TypeInfo(string), TMyPanel, "Caption", nil).

Пробовал, Дэльфа ругается на RegisterPropertyEditor - говорит, не знаю, мол, такого :o(


 
Sergey_Masloff   (2005-11-03 09:17) [5]

>на RegisterPropertyEditor - говорит, не знаю, мол, такого
а в справку заглянуть?


 
umbra ©   (2005-11-03 10:39) [6]


> аналогичного TChart


а от кого наследуется TChart?


 
den303 ©   (2005-11-04 11:24) [7]


> [5] Sergey_Masloff   (03.11.05 09:17)
> >на RegisterPropertyEditor - говорит, не знаю, мол, такого
>
> а в справку заглянуть?

Заглядывал, справка тоже такого не знает, почему и спрашиваю


> [6] umbra ©   (03.11.05 10:39)
>
> > аналогичного TChart
>
>
> а от кого наследуется TChart?

Не в курсе. Вроде бы - ни от кого, хотя могу ошибаться, не смотрел. Есть какие-либо соображения на сей счёт?


 
Sergey Masloff   (2005-11-04 11:26) [8]

den303 ©   (04.11.05 11:24) [7]
>Заглядывал, справка тоже такого не знает, почему и спрашиваю
Неправда, знает. Специально проверил на D6


 
umbra ©   (2005-11-04 11:34) [9]

В делфи часто все свойства и методы контролов, например TButton, реализованы в предке (TCustomButton), а в самом TButton только изменена область видимости свойств и методов. Поэтому, если TChart наследуется от какого-нибудь TCustomChart, то скорей всего и Вам надо наследоваться от TCustomChart и в своем компоненте прописать в published только нужные свойства и методы.


 
den303 ©   (2005-11-04 11:40) [10]


> Sergey Masloff   (04.11.05 11:26)

Хммм... Что-же у меня со справкой, глюки, что-ли... Тоже специально сейчас перепроверл - нету :o(  Не запостите?


> umbra ©   (04.11.05 11:34)

Спасибо за инфу, щас попробую


 
Sergey Masloff   (2005-11-04 14:30) [11]

Ну вот

Allows a component to bring up a custom property editor from the Object Inspector.

Unit

DesignIntf

Category

design tool registration routines

Delphi syntax:

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

C++ syntax:

extern PACKAGE void __fastcall RegisterPropertyEditor(Typinfo::
PTypeInfo PropertyType, System::TMetaClass* ComponentClass, const AnsiString PropertyName, System::TMetaClass* EditorClass);

Description

Call RegisterPropertyEditor to associate the property editor class specified by the EditorClass parameter with the property type specified by the PropertyType parameter.

When a component is selected, the Object Inspector creates a property editor for each of the component"s properties, based on the type of the property.  For example, if the property type is an Integer, the property editor for Integer will be created (by default that would be TIntegerProperty). Most properties do not need specialized property editors.  For example, if the property is an ordinal type the default property editor will restrict the range to the subtype range.

When a property type can not be properly edited using the default property editor or one of the existing property editors, use RegisterPropertyEditor to associate a custom property editor with the property type. This is typically because the property is an object.

When registering a property editor, set PropertyType to the type information pointer. In Delphi, the type information pointer is returned by the TypeInfo function. For example, TypeInfo(TPropertyObject). In C++, if the property type is a class, you can use the __typeinfo macro to obtain this pointer. For other types, you can obtain the type information pointer from a published property of the same type. For example:

PTypeInfo TypeInfo;
PPropInfo PropInfo = GetPropInfo(__typeinfo(TForm), "BorderStyle");
if (PropInfo)

 TypeInfo = *(PropInfo->PropType);

Set the ComponentClass parameter to restrict the property editor to a component class and its descendants. Setting ComponentClass to nil (Delphi) or NULL (C++) associates the property editor with the property type for any component.

Set the PropertyName parameter to restrict the property editor to properties with a specific name as well as the specified property type. Setting PropertyName to an empty string associates the property editor with any property of the specified type.

Set the EditorClass parameter to the class of the property editor that should be displayed when the property is selected in the Object Inspector. This class must be a descendant of TBasePropertyEditor that implements the IProperty interface.

А вообще ты uses DesignIntf не написал наверное


 
den303 ©   (2005-11-08 12:46) [12]

Извините, что долго не отвечал - с дипломом бегал, а инет только на работе.


> umbra ©   (04.11.05 11:34) [9]

Биг сенкс за подсказку направления, и правда, наследовался от TCustomChart - все методы исчезли, а в свойствах остались лишь размеры да для справки поля. Добавил нужные - и вуаля!


> Sergey Masloff   (04.11.05 14:30) [11]

Что-то я так и не догнал. Дельфы и 6 и 7 ругаются на отсутствие DesignIntf. И в справке нет ничего. Обе версии enterprise, до сих пор не жаловался. Что за дела, интересно... :o(


 
TUser ©   (2005-11-08 14:32) [13]

можно перекрыть его своим "пустым" свойством


 
TUser ©   (2005-11-08 14:33) [14]

хотя все-равно не спрячется - можно будет вызвать через приведение типов



Страницы: 1 вся ветка

Форум: "Основная";
Текущий архив: 2005.12.04;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.49 MB
Время: 0.04 c
10-1108842379
Hmm
2005-02-19 22:46
2005.12.04
Чтение строк из существующего doc-файла (word)... как?


1-1130204643
маленький человек
2005-10-25 05:44
2005.12.04
Частичная прозрачность


14-1131786030
lookin
2005-11-12 12:00
2005.12.04
Общая проблема - отсутствие реального опыта


4-1128006382
NikNil
2005-09-29 19:06
2005.12.04
Как получить список всех пользователей.


14-1132129270
Антоний
2005-11-16 11:21
2005.12.04
Про обновление Win2000ProRus





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский