Ver Mensaje Individual
  #1  
Antiguo 01-10-2007
MON___ MON___ is offline
Miembro
 
Registrado: abr 2007
Ubicación: Salamanca (España)
Posts: 84
Reputación: 18
MON___ Va por buen camino
Exception class EInvvalidOperation...

Estoy creando un sencillo componente descendiente de TCustomComboBox; intento cargar en un combo las provincias o las regiones españolas ordenadas alfabéticamente.

Al cargar los nombres (items.loadFromStream) me da el error: Exception class EInvalidOperation with message 'Control' has no parent window

He aquí el código fuente:

Código Delphi [-]
implementation

{$R *.dfm}
{$R hispania.res}

  // TCustomComboHispania
  type
    TCustomComboHispania = class(TCustomComboBox)
    private
      FProvincias : boolean;
      procedure SetProvincias(Value : boolean);
    protected
    public
      constructor Create(AOwner : TComponent); override;
      property Provincias : boolean read FProvincias write SetProvincias; 
    published
      
  end;

  constructor TCustomComboHispania.create(AOwner : TComponent);
  begin
    inherited Create(AOwner);
    style := csDropDownList;
    ShowHint := True;
    Sorted := false;
    Provincias := True;
  end;

  procedure TCustomComboHispania.SetProvincias(Value : boolean);
    var
     R : TResourceStream;
  begin
    FProvincias := Value;
    R := TResourceStream.create(hInstance, 'PROVINCIAS_ESPANNOLAS', RT_RCDATA);
    try
      items.loadFromStream(R);
    finally
      R.Free;
    end;

  end;

 /////////////////////////////////////////////////////////////////////////////

 // PROBANDO EL OBJETO ANTES DE INSTALARLO EN LA PALETA DE COMPONENTES

 var
  Combo : TCustomComboHispania;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Combo := TCustomComboHispania.create(form1);
  Combo.left := 30;
  Combo.Top := 30;
  Combo.parent := self;
end;

end

Última edición por dec fecha: 01-10-2007 a las 23:02:50.
Responder Con Cita