多谢

解决方案 »

  1.   


    procedure ScreenCap(LeftPos,TopPos,
    RightPos,BottomPos:integer);
    var
    RectWidth,RectHeight:integer;
    SourceDC,DestDC,Bhandle:integer;
    Bitmap:TBitmap;
    begin
    RectWidth:=RightPos-LeftPos;
    RectHeight:=BottomPos-TopPos;
    SourceDC:=CreateDC('DISPLAY','','',nil);
    DestDC:=CreateCompatibleDC(SourceDC);
    Bhandle:=CreateCompatibleBitmap(SourceDC,
    RectWidth,RectHeight);
    SelectObject(DestDC,Bhandle);
    BitBlt(DestDC,0,0,RectWidth,RectHeight,SourceDC,
    LeftPos,TopPos,SRCCOPY);
    Bitmap:=TBitmap.Create;
    Bitmap.Handle:=BHandle;
    BitMap.SaveToStream(BmpStream);
    BmpStream.Position:=0;
    LeftSize:=BmpStream.Size;
    Bitmap.Free;
    DeleteDC(DestDC);
    ReleaseDC(Bhandle,SourceDC);
    end;
      

  2.   

    其中ScreenCap是自定义函数,截取屏幕指定区域, 
    代码如下: 
    procedure TClient.ScreenCap(LeftPos,TopPos, 
    RightPos,BottomPos:integer); 
    var 
    RectWidth,RectHeight:integer; 
    SourceDC,DestDC,Bhandle:integer; 
    Bitmap:TBitmap; 
    begin 
    RectWidth:=RightPos-LeftPos; 
    RectHeight:=BottomPos-TopPos; 
    SourceDC:=CreateDC('DISPLAY','','',nil);
    {创建源设备环境,DISPLAY为显示器}DestDC:=CreateCompatibleDC(SourceDC); 
    {创建和SourceDC兼容的目标设备环境}
    Bhandle:=CreateCompatibleBitmap(SourceDC, 
    RectWidth,RectHeight);
    {创建一个和SourceDC兼容的内存设备环境,并返回其设备句柄} 
    SelectObject(DestDC,Bhandle); BitBlt(DestDC,0,0,RectWidth,RectHeight,SourceDC, 
    LeftPos,TopPos,SRCCOPY); Bitmap:=TBitmap.Create; 
    Bitmap.Handle:=BHandle; 
    BitMap.SaveToStream(BmpStream); 
    BmpStream.Position:=0; 
    LeftSize:=BmpStream.Size; 
    Bitmap.Free; 
    DeleteDC(DestDC); 
    ReleaseDC(Bhandle,SourceDC); 
    end;
      

  3.   

    function TForm1.CaptureScreen(): TBitmap;
    var
     DC : HDC;
     ABitmap  : TBitmap;
     CI: TCursorInfo;
    begin
     DC := GetDC(GetDesktopWindow);
     ABitmap := TBitmap.Create;
     try
        ABitmap.Width := GetDeviceCaps(DC,HORZRES);
        ABitmap.Height := GetDeviceCaps(DC,VERTRES);//  ScreenBmp.Width := screen.Width;
    //  ScreenBmp.Height := screen.Height;
    //  ABitmap.PixelFormat := pf8Bit;    BitBlt(ABitmap.Canvas.Handle,
               0,
               0,
               ABitmap.Width,
               ABitmap.Height,
               DC,
               0,
               0,
               SRCCOPY);
        ZeroMemory(@CI,SizeOf(CI));
        CI.cbSize := SizeOf(CI);
        if GetCursorInfo(CI) then
        DrawIconEx(ABitmap.Canvas.Handle,
                   CI.ptScreenPos.X,
                   CI.ptScreenPos.Y,
                   CI.hCursor,
                   16,
                   16,
                   0,
                   0,
                   DI_DEFAULTSIZE OR DI_NORMAL); finally
        ReleaseDC(GetDesktopWindow,DC);
     end;
     Result := ABitmap;
    end;
    转贴
      

  4.   

    core_blood(猴子学代码) :你有没有用过这段代码?
      

  5.   

    var desktop:Tcanvas;
    将当前显示画面抓取到一个paintbox中:
    begin
      desktop:=Tcanvas.create;
      with desktop do 
      handle:=getwindowsdc(getdesktopwindow);
      with paintbox1.canvas do
      begin
        copyrect(rect(0,0,paint1box.width,panit1box.height),desktop,rect(0,0,screen.width,screen.height));
      end;
    end;
      

  6.   

    to tjff2000(fengyun) 
    这一句:handle:=getwindowsdc(getdesktopwindow);怎么理解啊?