Home > Back-end >  Why BeginThread create threads in the drawing code doesn't work?
Why BeginThread create threads in the drawing code doesn't work?

Time:09-29

Why BeginThread create threads in the drawing code (MovetoEx, LineTo) have no effect? Code to remove the thread calls is no problem,

CodePudding user response:

Drawing code if it is to use Canvas, so need to resource conservation,
I don't remember is TCanvas BeginUpdate & amp; EndUpdate or Lock, UnLock,
I suggest you to post your own code,

CodePudding user response:

Is Canvase.
Roughly as follows:
Void StartGifPlay (HDC HDC, WORD x, WORD y, STR TMemoryStream * and bool bStream)//play GIF animation
{
Cs. Hdc=Hdc;////Hdc to form a frmShow - & gt; Img - & gt; Canvas - & gt; Handle;
ShowImg BeginThread (0, 0, (TThreadFunc), (LPVOID) (& amp; Cs), 0, 0);//open the new process to play the GIF
}
Long __fastcall ShowImg (LPVOID pParam)
{
Cs * PCS=* (Cs) pParam;
HDC dc PCS - & gt; Hdc.
MovetoEx (dc, 0, 0);
Lineto (dc, 100100); <===this two drawing code is invalid, interface effect see
return 0;
}
=========
If the drawing code are placed outside the thread is no problem,

CodePudding user response:

The main thread is responsible for the drawing, the child thread processing data
  • Related