首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

c.Handle:=GetDC(h);这句代码老是报:Incompatible types: 'QPainterH' and 'HDC'解决办法

2012-03-01 
c.Handle:GetDC(h)这句代码老是报:Incompatible types: QPainterH and HDCc.Handle:GetDC(h)这句

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单元

热点排行