0

I have this Delphi function:

function DevuelveResumenEventos(cnnBBDD : TADOConnection;sFecha,sHora,sCtrlPac : string) : TStream;
var
   sTextoArmado : string;
   stCarga : TStringStream;
begin
   with TADOTable.Create(Application.MainForm) do
   try
      sTextoArmado := '';
      Connection := cnnBBDD;
      TableName := 'EAPC_EVENTOS';
      Filter := 'EAPC_FECHA = '+sFecha+' and EAPC_HORA = '+sHora+' and EAPC_CTRL_PAC = '+sCtrlPac;
      Filtered := True;
      Open;
      while not Eof do
      begin
         sTextoArmado := sTextoArmado + FormatDateTime('dd-mm-yyyy', FieldValues['EAPC_FECHA_EVENTO'])+
                         ' '+MinutsToStr(FieldValues['EAPC_HORA_EVENTO'])+
                         '  ('+Trim(FieldValues['EAPC_LOGIN_USER'])+
                         ') - '+FieldByName('EAPC_EVENTO').AsString+CRLF+CRLF;

         Next;
      end;

      **stCarga := TStringStream.Create(sTextoArmado);
      with TRichEdit.Create(Application.MainForm) do
      begin
         Parent := Application.MainForm;
         Text := sTextoArmado;
         Lines.SaveToStream(stCarga);
         Free;
      end;
   finally
      Close;
      Free;
   end;
   Result := stCarga;**
end;

The intention is to retrieve a series of RTF formated texts, concatenate them with other texts and return them in a single TStringStream to be displayed in a TRichEdit in a form.

How can I skip the "use the on-the-fly RichEdit" and send the resulting texts as a TStringStream?

TiammatMX
  • 31
  • 2
  • 5
  • TRichEdit in Delphi 6 can not handle wide strings. So what would be the purpose of the String Stream? If you want a unicode (widechar) capable Rich Edit control, either (a) get a unicode version of delphi or (b) get the TNT Unicode controls and install them. – Warren P May 11 '12 at 23:08
  • Where does widestring come in to play in the above code? – Sertac Akyuz May 11 '12 at 23:51
  • RTF is an ASCII-based format to begin with. There is no need to involve WideString. Even with a Unicode-enabled RichEdit, the actual RTF data will still be ASCII encoded. As for the actual question of retrieving RTF for text without using a dynamic `TRichEdit`, try using a [windowless rich edit control](http://msdn.microsoft.com/en-us/library/windows/desktop/bb787613.aspx) and the `ITextServices` interface. Give it the desired plain text, and then send it an `EM_STREAMOUT` message to get the RTF. – Remy Lebeau May 12 '12 at 04:27

0 Answers0