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

关于抓图的有关问题

2012-03-08 
关于抓图的问题//用BITBLT函数实现位图拷贝(即窗口抓图)varHDCScreen:HDCiWidth,iHeight:IntegertmpRect

关于抓图的问题
//用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文件的电影图,而其他的只能抓到播放器边框的图(即抓到的播放器窗口里是黑屏,就和没播放电影一样)?请大侠们指教。。。

[解决办法]
视频截图需要特殊技术的,这么截是不行的,可以问问ly_liuyang
[解决办法]
帮顶

[解决办法]
自己看http://lysoft.g4soft.net/article.asp?id=12

热点排行