請教檔案下載範例問題 |
答題得分者是:william
|
cyl
中階會員 發表:163 回覆:171 積分:66 註冊:2002-07-11 發送簡訊給我 |
|
william
版主 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
|
cyl
中階會員 發表:163 回覆:171 積分:66 註冊:2002-07-11 發送簡訊給我 |
|
william
版主 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
引言:Canvas does not allow drawingIt means the canvas is invalid or it is still under someone else control for drawing. This is usually casued by unsynchronized threads accessing the GUI components. VCL is not thread safe so any update should be performed within the main thread. Refer to the original question. I think the main thread try to invalidate the form/controls while IBindStatusCallback is still working on the controls. To improve the situtation, try: procedure Tmythread.Execute; var D:IBindStatusCallback; begin FreeOnTerminate := True; D:=mybind.create; if URLDownloadToFile(nil,PChar(form1.edit1.text),PChar(form1.edit2.text),0,D)=0 then ShowMessage(' Download completed successfully : ' form1.edit1.text) else ShowMessage('Error during Download ' form1.edit1.text); Terminate; end; procedure TForm1.Button1Click(Sender: TObject); begin mythread:=Tmythread.Create(false); if (checkbox1.Checked = true) and (edit3.text<>'') then timer1.Enabled:=true; repeat Application.ProcessMessages; sleep(10); // add more if needed until mythread.Terminated or _abort; end;This is NOT a solution! It just reduces the error rate. BTW, mythread is a global variable and reusing it this way (create a new thread and associate it with mythread every time the button is clicked) may produce unexpected results... |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |