Posted by Gregory on August 07, 2007
In Reply to Another small problem posted by Chris Nevin on
August 04, 2007
: I have now run across the problem that using copying and pasting frequently in memo's
causes a flicker on the text, does anyone know how to avoid this? I have seen ticker components (effectively
what I am doing) that say they
are 'flickerless' so I guess it must be a known problem with a solution?
: Thanks
: Chris
I did tests with following code and have no flicker with Delay at 100 milliseconds or higher. Just very little bit flicker when Delay is less then 50 to 60 msec.
procedure TForm1.Button1Click(Sender: TObject);
const
Delay = 100; // smaller = faster, greater = slower
var
S: string;
i: integer;
Start: DWORD;
begin
S := Memo1.Text;
Memo2.SetFocus;
i := 0;
while i < Length(S) do begin
inc(i);
if S[i] >= ' ' then begin // printable character
Memo2.SelStart := Memo2.GetTextLen;
Memo2.SelText := S[i];
end
else if S[i] = #13 then // carriage return
Memo2.Lines.Add('');
Start := GetTickCount;
while GetTickCount < Start + Delay do
Application.ProcessMessages;
end;
end;
Completely flickerless is not possible by adding text to Delphi TMemo. You should output text direcly to Canvas and redraw only changed part of Canvas, more complicated ;)
Or draw directly using OpenGL or DirectX, still more complicated, or else obtain special component ;)
Related articles
Follow Ups
Post a Followup
DelphiLand Club members: enter your Membership password.
Guests can get a Forum Guest password by subscribing to the DelphiLand Newsletter.