与大家讨论一个问题,QQ右键菜单用键盘的PrintScreenSysRp可以抓下来,但用代码却抓不下来,不知何解,不信你试下:
procedure TForm1.GetActiveWndImg(b:TBitmap);
 
var C:TCanvas; H:HDC; R:TRect; hand:THandle;
 
begin 
    
C:=TCanvas.Create; 
   
 Hand:= GetForegroundWindow(); 
  
  if hand=0 then exit; 
    H:=GetWindowDC(Hand);//取得这个窗口的句柄 
    try 
    
 GetWindowRect(hand,R);//取得这个窗口的大小,将其赋给位图对象 
 
    B.Width:=R.Right-R.Left; 
     B.Height:=R.Bottom-R.Top; 
     C.Handle:=H; 
  
   B.Canvas.CopyRect(Rect(0,0,B.Width,B.Height),C 
     ,Rect(0,0,B.Width,B.Height)); 
  
  finally 
   
  C.Free; 
     
ReleaseDC(Hand, H);    
 end; end;