General TRichView support forum. Please post your questions here
mohsen24000
Posts: 75 Joined: Fri Jan 06, 2012 8:13 pm
Post
by mohsen24000 » Sat Dec 22, 2012 3:51 pm
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]
mohsen24000
Posts: 75 Joined: Fri Jan 06, 2012 8:13 pm
Post
by mohsen24000 » Sat Dec 22, 2012 6:52 pm
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 » Sun Dec 23, 2012 2:14 pm
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 » Sun Dec 23, 2012 2:27 pm
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 » Wed Dec 26, 2012 12:08 pm
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.