c.Handle:=GetDC(h);这句代码老是报:Incompatible types: 'QPainterH' and 'HDC'
c.Handle:=GetDC(h); 这句代码老是报编译错误:Incompatible types: 'QPainterH' and 'HDC'
这个怎么解决啊??
功能是实现截取当前活动窗口。
源代码如下(网络找的):
var
b:TBitMap;
c:TCanvas;
r:TRect;
h:THandle;
begin
b:=nil;
c:=nil;
try
b:=TBitMap.Create;
c:=TCanvas.Create;
h:=GetActiveWindow;
c.Handle:=GetDC(h);
GetWindowRect(h,r);
with r do r:=Rect(0,0,Right-Left,Bottom-Top);
b.Width:=r.Right;
b.Height:=r.Bottom;
b.Canvas.CopyRect(r,c,r);
b.SaveToFile('C:\x.bmp');
finally
b.Free;
c.Free;
end;
end;
[解决办法]
包含有关的单元了吗?如Windows,Graphics单元