procedure TForm1.btn1Click(Sender: TObject); begin TThread.CreateAnonymousThread( procedure var I:Integer; begin for I := 0 to 9999 do begin Sleep(50); 获取指定窗口信息; lbl1.Caption:=IntToStr(I+1); end; end ).Start; end;
procedure TForm1.SetBmpArr(bitmap: TBitmap; var BmpArr: TBmpArr); var Y:Integer; begin SetLength(BmpArr,bitmap.Height); for Y := 0 to bitmap.Height-1 do begin BmpArr[Y]:=bitmap.ScanLine[Y]; end; end;
自己解决了,代码如下 procedure TForm1.btn1Click(Sender: TObject); begin TThread.CreateAnonymousThread( procedure var I:Integer; begin bitmap:=TBitmap.Create; ScreenCanvas:=TCanvas.Create; N:=0; for I := 0 to 999 do begin //Sleep(1000); 获取指定窗口信息; lbl1.Caption:=IntToStr(I+1); end; ReleaseDC(0,DC); SetLength(BmpArr,0); ScreenCanvas.Free; bitmap.Free; end ).Start; end;
procedure TForm1.SetBmpArr(bitmap: TBitmap; var BmpArr: TBmpArr); var Y:Integer; begin if Length(BmpArr)>0 then SetLength(BmpArr,0); SetLength(BmpArr,bitmap.Height); for Y := 0 to bitmap.Height-1 do begin BmpArr[Y]:=bitmap.ScanLine[Y]; end; end;
function TForm1.获取指定窗口信息: TStringList; var R:TRect;