Craig Capel - 2002-05-04

Is it me or is SelText compared to that of Richedit slow and i mean very slow, I am writing a chat client and rx - lib was the only one i could find (which btw seems to be the best going for Delphi) which worked with Delphi 6 and could handle insertation of BMP's. When i say it's slow one of the routines is a Fade, so For A:=1 to 33 for example msg:='<red>text to fade blah <green>';

Richedit.SelText:=Msg[a];

Loop through outputting colours...
Is there any method of speeding it up? Turning on stuff that should be normall off ?

Also - Anyone noticed that in order to Scroll you HAVE to give it focus, well i found some code that makes it scroll but it's a little buggy when posting large sections of text.

procedure ScrollToEnd(display: TRxRichEdit);
Var
  Oldfont: HFont;
  DC: THandle;
  Tm: TTextMetric;
  TheRect: TRect;
  index, lines: Integer;
begin
  DC:=GetDC(display.Handle);
  try
    OldFont:=SelectObject(DC,display.Font.Handle);
    try
      GetTextMetrics(DC,Tm);
      display.Perform(EM_GETRECT,0,longint(@TheRect));
      index:=(tm.tmInternalLeading);
    finally
      SelectObject(DC,Oldfont);
    end;
  finally
    ReleaseDC(display.Handle,DC);
  end;
  lines:=SendMessage(display.Handle,EM_GETFIRSTVISIBLELINE,0,0);
    SendMessage(display.Handle,EM_LINESCROLL,0,(index-1));
  FaceUsed:=False;
end;

Anyone have a better way?..

Thanks

Craig C.