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,
type
TSDIAppForm = class(TForm)
procedure EstablecerInicio(Sender: TObject);
var
SDIAppForm: TSDIAppForm;
objVentNot: TObjectList;
implementation
uses BasDat,
{$R *.dfm}
procedure TSDIAppForm.EstablecerInicio(Sender: TObject);
begin
objVentNot := TObjectList< TNota > .Create(False);
objVentNot.Add(TNota.Create(nil));
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,
type
TNota = class(TForm)
RVVerNota: TRichView;
private
objVentNot: TObjectList< TNota >; iNota: Integer; public
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.