Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 15-11-2014
Avatar de danielmj
danielmj danielmj is offline
Miembro
 
Registrado: jun 2011
Posts: 383
Poder: 13
danielmj Va por buen camino
Guardar ListView como Texto Plano

Hola,

Sigo con la lista de otro post anterior a este, solo que esta vez el problema es otro. Intento guardar el contenido de la lista en un archivo de texto plano, buscando información por internet, encontre este código, que imagino ya habreis visto antes:

Código Delphi [-]
procedure guardarListViewFichero (AListView: TListView; sFileName: string);
var
  idxItem, idxSub, IdxImage: Integer;
  F: TFileStream;
  pText: PChar;
  sText: string;
  W, ItemCount, SubCount: Word;
  MySignature: array [0..2] of Char;

begin
  // Inicio
  with rForm.Lista do
  if rForm.saveDialog1.Execute then
  begin
    ItemCount := 0;
    SubCount  := 0;
    //****
    MySignature := 'txt';
    //  ListViewFile
    F := TFileStream.Create(rForm.saveDialog1.FileName, fmCreate or fmOpenWrite);
    F.Write(MySignature, SizeOf(MySignature));

    if Items.Count = 0 then
      // List is empty
      ItemCount := 0
    else
      ItemCount := Items.Count;
      F.Write(ItemCount, SizeOf(ItemCount));

    if Items.Count > 0 then
    begin
      for idxItem := 1 to ItemCount do
      begin
        with Items[idxItem - 1] do
        begin
          // Guardamos los SubItems
          if SubItems.Count = 0 then
            SubCount := 0
          else
          begin
          SubCount := Subitems.Count;
          F.Write(SubCount, SizeOf(SubCount));
          // Guardamos el Index
          IdxImage := ImageIndex;
          F.Write(IdxImage, SizeOf(IdxImage));
          // Guardamos la Caption
          sText := Caption;
          w     := Length(sText);
          pText := StrAlloc(Length(sText) + 1);
          StrPLCopy(pText, sText, Length(sText));
          F.Write(w, SizeOf(w));
          F.Write(pText^, w);
          StrDispose(pText);
          end;
          if SubCount > 0 then
          begin
            for idxSub := 0 to SubItems.Count - 1 do
            begin
              // Guardamos los Items y SubItems
              sText := SubItems[idxSub];
              w     := Length(sText);
              pText := StrAlloc(Length(sText) + 1);
              StrPLCopy(pText, sText, Length(sText));
              F.Write(w, SizeOf(w));
              F.Write(pText^, w);
              StrDispose(pText);
            end;
          end;
        end;
      end;
    end;
    F.Free;
  end;

end;

En la opcion "crear informe" del popup menú tengo esto:
Código Delphi [-]
procedure TrForm.Crearinforme1Click(Sender: TObject);
begin
    guardarListViewFichero(Lista, SaveDialog1.FileName);
end;

Aparentemente todo va bien, quiero decir que no da error en tiempo de compilación, pero cuando intento crear el informe, me tira un error de "stack overflow" como si hubiera desbordamiento de pila, y la verdad, no sé donde está el error (me refiero en el código)

¿alguna idea? Gracias y un saludo.
__________________
La juventud pasa, la inmadurez se supera, la ignorancia se cura con la educación, y la embriaguez con la sobriedad, pero la estupidez dura para siempre. Aristofanes.
Responder Con Cita
 



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

Temas Similares
Tema Autor Foro Respuestas Último mensaje
TDbGrid con un campo RTF. ¿Se puede visualizar como texto plano? TiammatMX OOP 20 01-03-2012 02:29:47
¿como guardar un archivo de texto como ANSI? JXJ Varios 2 09-09-2011 21:26:29
Cargar exe como texto plano _cero_ C++ Builder 4 14-12-2010 08:39:14
como agregar texto a un listview kurono Varios 4 10-11-2009 04:23:23
Guardar Archivo de Texto como en Excel BlueSteel Varios 4 26-09-2007 17:11:38


La franja horaria es GMT +2. Ahora son las 06:59:40.


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