delphi中关于线程的问题,急!!
我是菜鸟,在线程中对ProgressBar操作时,当ProgressBar初始visible属性为false,而在线程中设置它的visible为true;则执行完线程后关闭窗口会提示句柄无效,这是为什么啊?
代码如下:
function MyThreadFunc(P:thandle):Longint;stdcall;begin with form1 do begin ProgressBar1.Visible:=true; end; end;procedure TForm1.Button1Click(Sender: TObject);var hThread:Thandle; ThreadID:DWord;begintry hThread:=CreateThread(nil,0,@MyThreadfunc,nil,0,ThreadID); finally if hthread<>0 then closehandle(hthread); end;end;