![]() |
![]() |
![]() |
![]() |
![]() |
FTP | ![]() |
![]() |
CCD | ![]() |
![]() |
Buscar | ![]() |
![]() |
Trucos | ![]() |
![]() |
Trabajo | ![]() |
![]() |
Foros | ![]() |
|
Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Temas de Hoy |
|
Herramientas | Buscar en Tema | Desplegado |
#1
|
||||
|
||||
Error de herencia en diseño con subcomponente
Mi problema es el siguiente tengo un componente(el codigo al final) que tiro en una forma(form1) y todo funciona perfecto luego creo una nueva forma que herede de la anterior(tform2 = class(Tform1)) y cuando trato de acceder a la propiedad boton(es un sub componente) me arroja un error de diseño("Access violation at address 007C7B16 in module 'vcl70.bpl'. Read of address 00000004.") no se cuan es el problema y por que no me da el error en la forma1 y en form2 si .
Gracias de antenmano A continuacion el codigo fuente. unit Boton_lookup; interface uses SysUtils, Classes, Controls, StdCtrls, Buttons, Messages, Types; type TBoton = class(TSpeedButton) Public Constructor Create(Padre: TComponent); Override; End; TBotonPosition = (bpArriba, bpAbajo, bpIzquierda, bpDerecha); TBoton_lookup = class(TComboBox) private FBotonEspacio: Integer; FBoton: TBoton; FBotonPosition: TBotonPosition; procedure SetBotonEspacio(const Value: Integer); procedure SetBotonPosition(const Value: TBotonPosition); protected procedure SetParent(Padre: TWinControl); override; procedure Notification(Componente: TComponent; Operacion: TOperation); override; procedure SetName(const Value: TComponentName); override; procedure CMVisiblechanged(var Message: TMessage); message CM_VISIBLECHANGED; procedure CMEnabledchanged(var Message: TMessage); message CM_ENABLEDCHANGED; procedure CMBidimodechanged(var Message: TMessage); message CM_BIDIMODECHANGED; public { Public declarations } constructor Create(Padre: TComponent); override; procedure SetBounds(ALeft,ATop,AWidth,AHeight: Integer); override; procedure InstalarBotonInterno; Published property Boton: TBoton read FBoton; property BotonPosition: TBotonPosition read FBotonPosition write SetBotonPosition; property BotonEspacio: Integer read FBotonEspacio write SetBotonEspacio; end; procedure Register; implementation procedure Register; begin RegisterComponents('MisComponentes', [TBoton_lookup]); end; { TBoton_lookup } procedure TBoton_lookup.CMBidimodechanged(var Message: TMessage); begin inherited; FBoton.BiDiMode := BiDiMode; end; procedure TBoton_lookup.CMEnabledchanged(var Message: TMessage); begin inherited; FBoton.Enabled := Enabled; end; procedure TBoton_lookup.CMVisiblechanged(var Message: TMessage); begin inherited; FBoton.Visible := Visible; end; constructor TBoton_lookup.Create(Padre: TComponent); begin inherited Create(Padre); FBotonPosition := bpDerecha; FBotonEspacio := 3; InstalarBotonInterno; end; procedure TBoton_lookup.InstalarBotonInterno; begin If Assigned(FBoton) Then exit; FBoton := TBoton.Create(Self); FBoton.FreeNotification(Self); //FBoton.FocusControl := Self; end; procedure TBoton_lookup.Notification(Componente: TComponent; Operacion: TOperation); begin inherited Notification(Componente, Operacion); If (Componente = FBoton) and (Operacion = opRemove) Then FBoton := Nil; end; procedure TBoton_lookup.SetBotonEspacio(const Value: Integer); begin FBotonEspacio := Value; SetBotonPosition(FBotonPosition); end; procedure TBoton_lookup.SetBotonPosition(const Value: TBotonPosition); var P: TPoint; begin If FBoton = Nil Then Exit; FBotonPosition := Value; Case Value Of bpArriba: P := Point(Left, Top - FBoton.Height - FBotonEspacio); bpAbajo: P := Point(Left, Top + Height + FBotonEspacio); bpIzquierda : P := Point(Left - FBoton.Width - FBotonEspacio, Top + ((Height - FBoton.Height) div 2)); bpDerecha: P := Point(Left + Width + FBotonEspacio, Top + ((Height - FBoton.Height) div 2)); end; FBoton.SetBounds(P.x, P.y, FBoton.Width, FBoton.Height); end; procedure TBoton_lookup.SetBounds(ALeft, ATop, AWidth, AHeight: Integer); begin inherited SetBounds(ALeft, ATop, AWidth, AHeight); SetBotonPosition(FBotonPosition); end; procedure TBoton_lookup.SetName(const Value: TComponentName); begin If (csDesigning In ComponentState) And ((FBoton.GetTextLen = 0) Or (CompareText(FBoton.Caption, Name) = 0)) Then FBoton.Caption := Value; inherited SetName(Value); If csDesigning In ComponentState Then Text := ''; end; procedure TBoton_lookup.SetParent(Padre: TWinControl); begin inherited SetParent(Padre); If FBoton = Nil Then exit; FBoton.Parent := Padre; FBoton.Visible := True; end; { TBoton } constructor TBoton.Create(Padre: TComponent); begin inherited Create(Padre); Name := 'Subboton'; SetSubComponent(True); end; end. Última edición por rastafarey fecha: 20-02-2004 a las 18:02:47. Razón: Pegue dos palabras |
|
|
![]() |
|