//用BITBLT函数实现位图拷贝(即窗口抓图)
var
HDCScreen : HDC;
iWidth,iHeight : Integer;
tmpRect : TRect;      //位图区域procedure CaptureControl;//抓图过程
begin
NoWait := True;
//获得图像的矩形区域和句柄
if FormMain.Pop_VideoWin.Checked = True then
    begin
    tmpRect := FormMovie.Panel1.ClientRect;
    HDCScreen := GetDC(FormMovie.Panel1.Handle);
    end
 else if  FormMain.Pop_FlashWin.Checked = True then
    begin
    tmpRect := FormFlashPlayer.ShockwaveFlash1.ClientRect;
    HDCScreen := GetDC(FormFlashPlayer.Panel2.Handle);
    end
 else if  FormMain.Pop_RealWin.Checked = True then
    begin
    tmpRect := FormRealPlayer.RealAudio1.ClientRect;
    HDCScreen := GetDC(FormRealPlayer.Panel2.Handle);
    end
 else if FormMain.Pop_FullDisplayWin.Checked = True then
    begin
    tmpRect := Rect(0,0,Screen.Width,Screen.Height);
    HDCScreen := GetDc(GetDesktopWindow);
    end
 else
    begin
    NoWait := False;
    while not NoWait do
     begin
      FormMain.Timer_Capture.Enabled := True;
      if (Getkeystate(VK_LBUTTON) > 0) or  (Getkeystate(VK_RBUTTON) > 0) then
         begin
          GetCursorPos(P1);
          tmpHWND := WindowFromPoint(P1);
          GetWindowRect(tmpHWND, tmpRect);
          HDCScreen := GetDc(tmpHWND);
          FormMain.Timer_Capture.Enabled := False;
          NoWait := True;
         end;
     end;
   end;
//建立位图
tmpBitmap :=TBitmap.Create;
iWidth := tmpRect.Right-tmpRect.Left;
iHeight := tmpRect.Bottom-tmpRect.Top;
tmpBitmap.Width := iWidth;
tmpBitmap.Height := iHeight;
iBitmapValide := True;
//复制窗口矩形区域到位图中
Bitblt(tmpBitmap.Canvas.Handle,0,0,iWidth,iHeight,
             HDCScreen,tmpRect.Left,tmpRect.Top, SRCCOPY);
//释放句柄
if FormMain.Pop_VideoWin.Checked = True then
    begin
    ReleaseDC(FormMovie.Panel1.Handle,HDCScreen);
    end
 else if  FormMain.Pop_FlashWin.Checked = True then
    begin
    ReleaseDC(FormFlashPlayer.Panel2.Handle,HDCScreen);
    end
 else if  FormMain.Pop_RealWin.Checked = True then
    begin
    ReleaseDC(FormRealPlayer.Panel2.Handle,HDCScreen);
    end
 else if FormMain.Pop_FullDisplayWin.Checked = True then
    begin
    ReleaseDC(GetDesktopWindow, HDCScreen);
    end
 else
    begin
    ReleaseDC(tmpHWND, HDCScreen);
    FormMain.Timer_Capture.Enabled := False;
    end;
end;
  为什么我只能抓到第一个MEDIAPLAYER文件的电影图,而其他的只能抓到播放器边框的图(即抓到的播放器窗口里是黑屏,就和没播放电影一样)?请大侠们指教

解决方案 »

  1.   

    视频截图需要特殊技术的,这么截是不行的,可以问问ly_liuyang
      

  2.   

    你需要的是OverlaySurface的截图技术,直接从视频加速器的缓存中获得YUV格式的数据
    这需要DirectX的Hook技术,比较复杂
    具体方法需有偿提供,呵呵~
      

  3.   

    自己看http://lysoft.g4soft.net/article.asp?id=12
      

  4.   

    大哥,你给得网页打不开:处理 URL 时服务器出错。请与系统管理员联系。
      

  5.   

    晕,怎么分没给上,是不是,FIREFOX浏览器刚才拦截了个提示框得问题??、