canvas does not allow drawing

General TRichView support forum. Please post your questions here
Post Reply
mohsen24000
Posts: 75
Joined: Fri Jan 06, 2012 8:13 pm

canvas does not allow drawing

Post by mohsen24000 »

Hello dear,
when i use 'chat demo' in TIdUDPServer onRead event:

Code: Select all

procedure TfrmMain.UpdateChat(msg: string);
begin
  ParseString(mChat,msg); // from chat demo
  mChat.Invalidate;
try
  mChat.Format;
except
  mChat.FormatTail;
end;
  mChat.Update;
  mChat.DeleteUnusedStyles(True, True, True);
  mChat.VScrollPos:= mChat.VScrollMax;
end;
this error Sometimes appear:
"canvas does not allow drawing"
[/code][/b]
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Is this code called in the context of the main thread?
mohsen24000
Posts: 75
Joined: Fri Jan 06, 2012 8:13 pm

Post by mohsen24000 »

Sergey Tkachenko wrote:Is this code called in the context of the main thread?
yes.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

What's the value of ThreadedEvent property?
(sorry for double checking)
mohsen24000
Posts: 75
Joined: Fri Jan 06, 2012 8:13 pm

Post by mohsen24000 »

Oh!
It was True and change it False and all things right.
i think resolved.
Thanks a lot.
--------------------------------
Is it possible to correct this problem with Threads!?
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

VCL is not thread-safe, any drawing must be made in the context of the main process. This is not only for our components, this is a VCL design.
If you need to initiate redrawing from a thread, use Synchronize.
Post Reply