![]() |
![]() |
| Paypal | FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
|||||||
| Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Buscar | Temas de Hoy | Marcar Foros Como Leídos |
![]() |
|
|
Herramientas | Buscar en Tema | Desplegado |
|
|
|
#1
|
|||
|
|||
|
Procedures Stream.WriteComponent and ReadComponent are
purposed for deal mainly with Root components (Form, DataModule, ...). Somewhen I was experimenting with components and wrote procedures for read/write non-root components from stream:
PS: When Reader reads a component from stream, initially it reads the Class Name of the component. Then (if the component has not been created before reading) Reader tries to find the Class Reference by Class Name. First, it searches the class in the RTTI-table of Root component. If there is any component of the same class in the Root, then success. Second, the Reader searches the class in the registered classes. If the class have been registered by RegisterClass (RegisterClasses), then success. Third, the Reader let user to resolve the Class Name to the Class Reference by himself (it calls OnFindComponentClass event handler). If all this attempts have failed, the Reader raise EClassNotFound "class <Class Name> not found". Use RegisterClasses to solve it. Última edición por rounin fecha: 06-10-2005 a las 14:23:22. |
|
#2
|
|||
|
|||
|
Thanks! Rounin. I think that your solution will help me. Very good explanation. Thanks again!
Saludos
__________________
Juan Pablo |
|
#3
|
||||
|
||||
|
Saludos
Rounin, Sabes escribir en español?, Lo digo porque en este foro la gran mayoría hablamos(o escribimos) en español. Entonces los forista que consulten este hilo y tenga pocos conocimiento del ingles estarán despistado. Ante todo, Es muy grata y muy buena tu ayuda (hasta a mi me has ayudado ). Espero seguir viendote por aqui![]()
__________________
Van Troi De León (Not) Guía, Code vB:=Delphi-SQL, ¿Cómo? Viajar en el tiempo no es teóricamente posible, pues si lo fuera, ya estarían aqui contándonos al respecto! |
|
#4
|
|||
|
|||
|
Saludos,
Estoy estudiando español, (yo periodicamente voy en comisiones de servicio a España) pero mi nivel de español no es bastante alto, y lo escribir en español todavía es dificil para mi. Lo siento. ![]() |
|
#5
|
||||
|
||||
|
Saludos
Cita:
![]() Cita:
![]()
__________________
Van Troi De León (Not) Guía, Code vB:=Delphi-SQL, ¿Cómo? Viajar en el tiempo no es teóricamente posible, pues si lo fuera, ya estarían aqui contándonos al respecto! |
|
#6
|
|||
|
|||
|
Saludos,
pienso que en tu caso necesita incluir flag csSubcomponent en tus subcomponentes: Código:
TDigitalDisplay = class(TCustomPanel)
private
FImage1: TImage;
FStaticText1: TStaticText;
FPopupMenu1: TPopupMenu;
{...}
published
property StaticText1: TStaticText read FStaticText1; {r/o}
property Image1: TImage read FImage1;
property PopupMenu1: TPopupMenu read FPopupMenu1;
{...}
end;
constructor TDigitalDisplay.Create(AOwner: TComponent);
function CreateSubComponent(AClass: TComponentClass): TComponent;
begin
Result := AClass.Create(Self);
Result.SetSubComponent(True); {!!!!!!!!}
Result.FreeNotification(Self);
if Result is TControl then TControl(Result).Parent := Self;
end;
var
MenuItem: TMenuItem;
begin
inherited;
{...}
FStaticText1 := CreateSubComponent(TStaticText) as TStaticText;
FStaticText2 := CreateSubComponent(TStaticText) as TStaticText;
FStaticText3 := CreateSubComponent(TStaticText) as TStaticText;
FImage1 := CreateSubComponent(TImage) as TImage;
FPopupMenu1 := CreateSubComponent(TPopupMenu) as TPopupMenu;
MenuItem := TMenuItem.Create(PopupMenu1);
FPopupMenu1.Items.Add(MenuItem);
with MenuItem do
begin
Caption := 'Configurar';
OnClick := PopupConfigurar;
end;
end;
procedure TDigitalDisplay.Notification(AComponent: TComponent; Operation: TOperation);
begin
inherited;
if (AComponent = FStaticText1) and (Operation = opRemove) then FStaticText1 := nil;
if (AComponent = FStaticText2) and (Operation = opRemove) then FStaticText2 := nil;
if (AComponent = FStaticText3) and (Operation = opRemove) then FStaticText3 := nil;
if (AComponent = FPopupMenu1) and (Operation = opRemove) then FPopupMenu1 := nil;
if (AComponent = FImage1) and (Operation = opRemove) then FImage1 := nil;
end;
Porque no en Create? |
|
#7
|
|||
|
|||
|
Cita:
, estuve con mucho trabajo.Los subcomponentes los creo en el metodo AfterConstruction porque en el constructor Create el componente aun no está creado y no puedo asignarle la variable Self a la propiedad Parent del subcomponente, ni tampoco pasarlo como Owner en la creación del subcomponente. O almenos eso entendí. Saludos y éxitos con el español.
__________________
Juan Pablo |
![]() |
| Herramientas | Buscar en Tema |
| Desplegado | |
|
|
|