Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

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

Los mejores trucos

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 07-08-2008
rauros rauros is offline
Miembro
 
Registrado: feb 2008
Ubicación: Alicante - Sax / Sax - Alicante
Posts: 235
Poder: 17
rauros Va por buen camino
RtfToTxt

Este truco es bastante útil para hacer editores de texto que lo colorean, para grabar los progresos en txt y no en rtf. Gracias a Miguel por la ayuda.

Código Delphi [-]
function RtfToTxt(Rtf: TStrings): TStrings;
 Var
  RtfInvisible: TRichEdit;
 Begin
  TrichEdit.Create(RtfInvisible);
  Try
   RtfInvisible.PlainText:=False;
   RtfInvisible.Lines:=Rtf;
   RtfInvisible.PlainText:=True;
   result:=RtfInvisible.lines;
  Finally
  if Assigned(RtfInvisible) then RtfInvisible.Free;
  end;
 end;
Responder Con Cita
  #2  
Antiguo 11-08-2008
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 18.233
Poder: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
¿Has probado este código?
Código Delphi [-]
 Var
  RtfInvisible: TRichEdit;
 Begin
  TrichEdit.Create(RtfInvisible);
  Try
   RtfInvisible.PlainText:=False;

(1º) Esto falla, puesto que la construcción es incorrecta; No se exactamente lo que querías hacer, pero lo que has hecho no está bien. En la última línea la variable RtfInvisible está sin asignar.

(2º) Por otro lado, me da la impresión de que al liberar la variable (valor devuelto), posiblemente estés provocando que otras partes del código que utilizan el objeto devuelto estén fallando al acceder a algo que ya has liberado.

Código Delphi [-]
   result:=RtfInvisible.lines;
  Finally
  if Assigned(RtfInvisible) then RtfInvisible.Free;
  end;

Creo que deberías corregirlo y añadir al menos un comentario con el texto correcto.

Responder Con Cita
  #3  
Antiguo 22-10-2008
Avatar de cHackAll
[cHackAll] cHackAll is offline
Baneado?
 
Registrado: oct 2006
Posts: 2.159
Poder: 20
cHackAll Va por buen camino
Código Delphi [-]
procedure RtfToTxt(Strings: TStrings);
begin
 with TRichEdit.Create(nil) do
  begin
   Visible := False;
   Parent := Application.MainForm;
   Text := Strings.Text;
   PlainText := True;
   Strings.Assign(Lines);
   Destroy;
  end;
end;

Modo de uso:

Código Delphi [-]
procedure TForm1.Button1Click(Sender: TObject);
begin
 ListBox1.Items.LoadFromFile('c:\leecher.rtf');
 RtfToTxt(ListBox1.Items);
end;

Saludos
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 20:38:59.


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