Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

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

Coloboración Paypal con ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 05-06-2014
pmarin pmarin is offline
Miembro
 
Registrado: jun 2006
Ubicación: Valencia( España )
Posts: 17
Poder: 0
pmarin Va por buen camino
(Solucionado)

Me contesto a mi mismo. He estado estudiando el problema en profundidad y he
encontrado 2 errores en el codigo anterior. Estos son los dos fallos que habia:

1) En el mundo de 64-bit es necesario crecer los parametros DWORD a DWORD_PTR.
Ya que DWORD_PTR se mapea a DWORD en sistemas 32-bits

2) La funcion CallBack debe estar definida y fuera del procedimiento que la va
a llamar.

Ahora he modificado el codigo y ahora funciona tanto en 32 bits como en 64 bits.

Código Delphi [-]
{ EditStreamReader callback function }
function EditStreamReader( dwCookie: DWORD_PTR; pbBuff: PByte;
     cb: LongInt; var pcb: Longint): LongInt; stdcall;
begin
     result := $0000;
     try
       pcb := TStream(dwCookie).Read(pbBuff^, cb) ;
     except
       result := $FFFF;
     end;
(*EditStreamReader*)
end;

procedure AppendToRichEdit(const source, destination : TRichEdit) ;
var
   rtfStream: TEditStream;
   sourceStream : TMemoryStream;

begin
   destination.Lines.BeginUpdate;
   sourceStream := TMemoryStream.Create;
   try
     source.Lines.SaveToStream(sourceStream) ;
     sourceStream.Position := 0;

     destination.MaxLength := destination.MaxLength + sourceStream.Size;

     rtfStream.dwCookie := DWORD_PTR(sourceStream) ;
     rtfStream.dwError := $0000;
     rtfStream.pfnCallback := @EditStreamReader;
     destination.Perform(
       EM_STREAMIN,
       SFF_SELECTION or SF_RTF or SFF_PLAINRTF, LPARAM(@rtfStream)
     ) ;
     if rtfStream.dwError <> $0000 then
       raise Exception.Create('Error appending RTF data.') ;
   finally
     sourceStream.Free;
     destination.Lines.EndUpdate;
   end;

(*AppendToRichEdit*)
end;
Responder Con Cita
  #2  
Antiguo 11-06-2014
pmarin pmarin is offline
Miembro
 
Registrado: jun 2006
Ubicación: Valencia( España )
Posts: 17
Poder: 0
pmarin Va por buen camino
(Otra Solucion)

Para los RichEdit de DevExpress la solucion anterior funciona simplemente cambiando lo siguiente:

Código Delphi [-]
 
with TcxRichEdit(destination.InnerControl) do
SendMessage(Handle,
EM_STREAMIN,
SFF_SELECTION or SF_RTF or SFF_PLAINRTF, LPARAM(@rtfStream));

Pero aqui les dejo otra solucion para estos mismos componentes. Es una forma mas lenta. La causa
de ello es que hay que seleccionar todo el texto del RichEdit de destino cada vez que se hace una
adicion. Pero si se hacen pocos adiciones, o el RichEdit de destino es pequeño puede valer la pena
olvidarse de los CallBacks.

Código Delphi [-]
 
procedure TSQLBuilder32.AppendToRichEdit(const source: TStream;
    destination : TcxRichEdit) ;
// ======================================================== //
// Name: AppendToRichEdit(source, destination)
//
var
   rtfStream  : TEditStream;
   ASelStart, ASelLength: Integer;
begin
   destination.Lines.BeginUpdate;
  with destination do
  begin
    ASelStart := SelStart;
    ASelLength := SelLength;
    try
      Properties.StreamModes := Properties.StreamModes + [resmSelection];
      try
        SelStart := ASelStart;
        SelLength := ASelLength;
        Lines.LoadFromStream(source);
        ModifiedAfterEnter := True;
      finally
        Properties.StreamModes := Properties.StreamModes - [resmSelection];
      end;
    finally
      destination.Lines.EndUpdate;
    end;
  end;
(*AppendToRichEdit*)
end;
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

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:00:18.


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