Ver Mensaje Individual
  #5  
Antiguo 17-05-2015
Avatar de nlsgarcia
[nlsgarcia] nlsgarcia is offline
Miembro Premium
 
Registrado: feb 2007
Ubicación: Caracas, Venezuela
Posts: 2.206
Reputación: 21
nlsgarcia Tiene un aura espectacularnlsgarcia Tiene un aura espectacular
albelg,

Cita:
Empezado por albelg
...como abrir varios archivos.txt en un mismo memo...


Revisa este código:
Código Delphi [-]
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
   Memo1.ScrollBars := ssBoth;
   Memo1.WordWrap := False;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
   openDialog : TOpenDialog;
   FileList : TStringList;
   i : Integer;

begin

   openDialog := TOpenDialog.Create(self);
   openDialog.InitialDir := GetCurrentDir;
   openDialog.Options := [ofFileMustExist, ofAllowMultiSelect];
   openDialog.Filter := 'Text Files | *.txt';

   if openDialog.Execute then
   begin
      for i := 0 to OpenDialog.Files.Count - 1 do
      begin
         FileList := TStringList.Create;
         FileList.LoadFromFile(openDialog.Files[i]);
         Memo1.Text := Memo1.Text + FileList.Text;
         FileList.Free;
      end;
   end;

   openDialog.Free;

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
   Memo1.Clear;
end;

end.
El código anterior (Versión 2 del Msg #3) en Delphi 7 sobre Windows 7 Professional x32, Permite abrir varios archivos .txt dentro de un TMemo uno a continuación del otro, como se muestra en la siguientes imágenes:





Espero sea útil

Nelson.
Responder Con Cita