Ver Mensaje Individual
  #3  
Antiguo 14-08-2013
jocaro jocaro is offline
Miembro
 
Registrado: sep 2011
Posts: 104
Reputación: 13
jocaro Va por buen camino
Hola Maeyanes.

En mi caso, desde la unidad principal, creo una instancia de TObjectList y voy generando instancias de la clase TNotas, que añado al ObjectList.

¿Es válida mi forma de plantearlo? ¿Existen alternativas mas correctas, simples o elegantes de hacerlo?. Gracias por tu ayuda.

El ejemplo del código usado es el siguiente:

Código Delphi [-]
unit SDIMAIN;

interface

uses Windows, Messages, Classes, Graphics, Forms, Controls, Menus, Dialogs,
// etc

type

  TSDIAppForm = class(TForm)
      procedure EstablecerInicio(Sender: TObject);

  // etc

var
  SDIAppForm: TSDIAppForm;

 { Ventanas de notas }
  objVentNot: TObjectList;

implementation

uses BasDat, 
// etc


{$R *.dfm}

procedure TSDIAppForm.EstablecerInicio(Sender: TObject);
begin

  objVentNot := TObjectList< TNota > .Create(False);

  { Creación de form para ver una nota (se crea un form cada vez que se
    selecciona ver una nota) }

  objVentNot.Add(TNota.Create(nil));

  { Asignar puntero a propiedad publica de la clase FNota }
  objVentNot[objVentNot.Count - 1].pVentNot := objVentNot;

  objVentNot[objVentNot.Count - 1].Show;
  
end;

end.

Código Delphi [-]
unit VerNota;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, 
  // etc

type
  TNota = class(TForm)
    RVVerNota: TRichView;
    //etc.
    
  private
    { Private declarations }
    objVentNot: TObjectList< TNota >; // O solo TObjectList
    iNota: Integer; // Indice de la nota dentro del ObjectList
  public
    { Public declarations }
    property pVentNot: TObjectList< TNota >
      read objVentNot
      write objVentNot;
  end;

var
  Nota: TNota;

implementation

{$R *.dfm}

procedure TNota.FormActivate(Sender: TObject);
begin
  iNota := objVentNot.IndexOf(Self);
end;

procedure TNota.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action := caFree;
  objVentNot.Remove(Self);
end;

procedure TNota.btnCopiarTextoPlanoClick(Sender: TObject);
begin
  RVVerNotaCopiarTextoPlano();
end;

procedure TNota.btnDchoCopiarTextoPlanoClick(Sender: TObject);
begin
  RVVerNotaCopiarTextoPlano();
end;

procedure TNota.RVVerNotaCopiarTextoPlano();
begin
  objVentNot[iNota].RVVerNota.CopyTextA;
end;

end.
Responder Con Cita