Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > OOP
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Coloboración Paypal con ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 07-09-2005
Avatar de mamcx
mamcx mamcx is offline
Moderador
 
Registrado: sep 2004
Ubicación: Medellín - Colombia
Posts: 3.939
Poder: 27
mamcx Tiene un aura espectacularmamcx Tiene un aura espectacularmamcx Tiene un aura espectacular
Aja...

y la duda es???
__________________
El malabarista.
Responder Con Cita
  #2  
Antiguo 09-09-2005
OscarG OscarG is offline
Miembro
 
Registrado: sep 2005
Posts: 35
Poder: 0
OscarG Va por buen camino
Más datos...

He hecho el cambio de TList por TInterfaceList, el fallo ocurre al pulsar en boton3 y a la 1ª pasada. Lo q hace el programa es crear una Lista con Interfaces de un objeto q almacena 2 números (uno por cada interfaz). Pulsando el primer botón, crearía un objeto y lo guardaría como interfaz en miLista que es de tipo TInterfaceList (se tendrían q pulsar varias veces para crear varios números). Luego pulsando el segundo botón, tendría q aparecer en cada listBox los nºs almacenados, un nº por cada tipo. Pero al pulsarlos fallan los métodos para meter los valores de la interfaz en el TListBox.


Venga aqui os dejo el código, un saludo y gracias por la ayuda.

Código Delphi [-]
 
unit Unit1;
interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;


type 
  INotas = interface
    ['{F5F6273D-A9C9-44C5-A666-A4F607E18374}']
    function getValor: Integer;
  end;


  INotas2 = interface
    ['{ADDD2B20-BC87-11D9-9718-0050FCAA723B}']
    function getValor2: Integer;
  end;

  TMisNotas = class(TInterfacedObject, INotas, INotas2)
    private
      numnotas, numnotas2: Integer;
    public
      constructor Create;
      destructor  Destroy;   
      function getValor: Integer;
      function getValor2: Integer;
    end;

  TForm1 = class(TForm)
    Boton: TButton;
    Lista: TListBox;
    Boton2: TButton;
    Lista2: TListBox;
    procedure BotonClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Boton2Click(Sender: TObject);
  private
    { Private declarations }
    MiLista:  TInterfaceList; //TList;
    procedure meterObjetoEnLista(interfaz:  INotas);
    procedure meterObjetoEnLista2(interfaz: INotas2);
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

constructor TMisNotas.Create;
begin
  inherited Create;

  numnotas:=  Random(100);

  numnotas2:=  100 + Random(100);
end;

destructor  TMisNotas.Destroy;
begin
  

  inherited Destroy;
end;

function TMisNotas.getValor: Integer;
begin
  Result:= numnotas;
end;

function TMisNotas.getValor2: Integer;
begin
  Result:= numnotas2;
end;

procedure TForm1.BotonClick(Sender: TObject);
var
  Objeto: TMisNotas;
begin
  MiLista.Add(TMisNotas.Create);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Randomize;
  MiLista:= TInterfaceList.Create;
end;

procedure TForm1.meterObjetoEnLista(interfaz:  INotas);
begin
  Lista.Items.Add(IntToStr(interfaz.getValor));
end;

procedure TForm1.meterObjetoEnLista2(interfaz:  INotas2);
begin
  Lista2.Items.Add(IntToStr(interfaz.getValor2));
end;

procedure TForm1.Boton2Click(Sender: TObject);
var
  i, cont: Integer;
begin
  Lista.Clear;
  Lista2.Clear;
  
  cont:= MiLista.Count;

  if (cont > 0) then
    for i:= 0 to cont - 1 do
    begin
      meterObjetoEnLista( INotas( MiLista.Items[i] ) );
      meterObjetoEnLista2( INotas2( MiLista.Items[i] ) );
    end;
end;

end.

Última edición por jmariano fecha: 09-09-2005 a las 14:33:18. Razón: Uso de la etiqueta [delphi]
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 13:46:46.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi