Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

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

Grupo de Teaming del ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 28-05-2014
pmarin pmarin is offline
Miembro
 
Registrado: jun 2006
Ubicación: Valencia( España )
Posts: 17
Poder: 0
pmarin Va por buen camino
Añadir el contenido de un TRichEdit a otro en 64 bits.

Hola,

este tema ya se trató en un otro tema (ver http://www.clubdelphi.com/foros/showthread.php?t=82322), y lo solucione
con el fabuloso código de Zarko Gajic Append or Insert RTF from one RichEdit to Another

El siguiente codigo funciona perfectamente en 32 bits. El problema aparece cuando lo compilo con 64 bits.
No existen errores de compilacion, pero la ejecución falla. He intentado adaptarlo por mi cuenta pero no
me aclaro con los punteros, LongInt, DWORD, etc.

Como TRichEdit uso los componentes DevExpress VCL, pero esto no es la causa del problema.

Por favor, ¿me podrían ayudar a convertir este codigo a 64 bits?

Saludos
Pablo

Código Delphi [-]
 
unit Unit1;
interface
uses
Windows, Classes, RichEdit, SysUtils, cxRichEdit;
implementation
procedure AppendToRichEdit(const source: TStream;
destination : TcxRichEdit) ;
// ======================================================== //
 
// Name: AppendToRichEdit(source, destination)
 
//
 
{ The TRichEdit control does not expose a method to append or insert a piece of RTF
text. It does have a Lines property to let you add more text - but you'll have
trouble if you want to append rich text formatted content - it will be added
as a (ASCII) simple text.
If you want to "move" the entire text from one rich editor to another you can
use streams - but the content of the "destination" rich editor will be totally
overwritten by the "source" editor's text.
Here's a function that allows appending or inserting RTF text from one Stream
to another - using rich edit specific callback functions.
Note: Include "RichEdit" into the USES section
}
var
rtfStream : TEditStream;
szError : string;
 
{ EditStreamReader callback function }
function EditStreamReaderCallback(
dwCookie: DWORD;
pbBuff: Pointer;
cb: LongInt;
pcb: PLongInt): DWORD; stdcall;
var
theStream: TStream;
dataAvail: LongInt;
begin
theStream := TStream(dwCookie);
with theStream do
begin
dataAvail := Size - Position;
Result := $0000;
if dataAvail <= cb then
begin
try
pcb^ := read(pbBuff^, dataAvail);
if pcb^ <> dataAvail then
Result := UINT(E_FAIL);
except
Result := $FFFF;
end;
end
else
begin
try
pcb^ := read(pbBuff^, cb);
if pcb^ <> cb then
Result := UINT(E_FAIL);
except
Result := $FFFF;
end;
end;
end;
end; (*EditStreamReader*)
begin
destination.Lines.BeginUpdate;
try
source.Position := 0;
rtfStream.dwCookie := DWORD(source) ;
rtfStream.dwError := $0000;
rtfStream.pfnCallback := @EditStreamReaderCallback;
with TcxRichEdit(destination.InnerControl) do
SendMessage(Handle,
EM_STREAMIN,
SFF_SELECTION or SF_RTF or SFF_PLAINRTF, LPARAM(@rtfStream));
if rtfStream.dwError <> $0000 then
begin
szError := Format('AppendToRichEdit: Error appending RTF data ' +
'with error = %s.', [ IntToStr(rtfStream.dwError) ]);
raise Exception.Create( szError );
end;
finally
destination.Lines.EndUpdate;
end;
(*AppendToRichEdit*)
end;
 
end.
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
Añadir el contenido de un TRichEdit a otro. TiammatMX OOP 10 23-02-2013 09:41:14
Leer pdf y cargar contenido en TRichEdit nena_yei OOP 4 15-07-2010 17:28:23
Copiar el texto de un TRichEdit a otro dec Trucos 0 02-07-2006 00:34:27
graficar el contenido de un TRichEdit ber Gráficos 2 22-11-2005 21:39:51
Como añadir el contenido de una tabla a otra maravert Tablas planas 2 16-10-2005 04:04:40


La franja horaria es GMT +2. Ahora son las 03:27:10.


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