PrintWindow is similar to WM_PRINT. Before calling PrintWindow, first select a bitmap into hdcBlt.
CDC *pDC = ::GetDC(hwnd)//hwnd is the handle of window wants to be printed; CDC *pCurrentDC = ::GetDC(hCurrentWnd)//handle of current window CRect rect(CPoint(0,0),CPoint(0,0)); CBitmap bitmap; ::GetClientRect(hwnd,&rect); bitmap.CreateCompatibleBitmap(pDC,rect.Width(),rect.Height()); pDC.SelectObject(&bitmap); ::SendMessage(hwnd,WM_PRINT,(WPARAM)pDC->m_hDC,(LPARAM)(PRF_CHILDREN|PRF_CLIENT)); pCurrent->BitBlt(0,0,rect.Width(),rect.Height(),pDC,SRCCOPY);代码不一定准确,不过我就是按照这样得步骤写得。 结果什么都没显示。请教大家: 1,窗口在被覆盖得时候,是不是也可以截取得到相应得图像。 2,如果可以得话,是不是用PrintWindow 或者WM_PRINT来实现。 3,如果是用以上方法来实现得话,请说说实现的时候应该注意什么,正确的步骤是什么。谢谢:)
CDC *pCurrentDC = ::GetDC(hCurrentWnd)//handle of current window
CRect rect(CPoint(0,0),CPoint(0,0));
CBitmap bitmap;
::GetClientRect(hwnd,&rect);
bitmap.CreateCompatibleBitmap(pDC,rect.Width(),rect.Height());
pDC.SelectObject(&bitmap);
::SendMessage(hwnd,WM_PRINT,(WPARAM)pDC->m_hDC,(LPARAM)(PRF_CHILDREN|PRF_CLIENT));
pCurrent->BitBlt(0,0,rect.Width(),rect.Height(),pDC,SRCCOPY);代码不一定准确,不过我就是按照这样得步骤写得。
结果什么都没显示。请教大家:
1,窗口在被覆盖得时候,是不是也可以截取得到相应得图像。
2,如果可以得话,是不是用PrintWindow 或者WM_PRINT来实现。
3,如果是用以上方法来实现得话,请说说实现的时候应该注意什么,正确的步骤是什么。谢谢:)
::PrintWindow(HWND,HDC,UINT);
这个API也需要HDC啊。
而且我含了winuser.H
载入了User32.lib
这个函数还是不能用啊。
PrintWindow还是找不到#include <winuser.h>
#pragma comment (lib,"Winspool.lib")CDC *pDC = ::GetDC(hwnd)//hwnd is the handle of window wants to be printed;
CDC *pCurrentDC = ::GetDC(hCurrentWnd)//handle of current window
CRect rect(CPoint(0,0),CPoint(0,0));
CBitmap bitmap;
::GetClientRect(hwnd,&rect);
bitmap.CreateCompatibleBitmap(pDC,rect.Width(),rect.Height());
pDC->SelectObject(&bitmap);
//::SendMessage(hwnd,WM_PRINT,(WPARAM)pDC->m_hDC,(LPARAM)(PRF_CHECKVISIBLE));
::PrintWindow(hwnd,pDC->m_hDC,PRF_CHECKVISIBLE);
pCurrent->BitBlt(0,0,rect.Width(),rect.Height(),pDC,SRCCOPY);
大概是这个样子么?
#define _WIN32_WINNT 0x0501include <winuser.h>
#pragma comment (lib,"Winspool.lib")::PrintWindow(hwnd,hDC,0/*这里也可以用PW_CLIENTONLY*/);
2000找不到PrintWindow();
我把winspool导出来,也没有找到printWindow
我想还是通过WM_PRINT来实现,
再进程之间传递DC,有什么好的办法么?
PrintWindow是被winspool.drv隐式导出的,所以你用Depends是看不到,只有在lib里面能记录到。
另外:PrintWindow 必须在XP以上版本进行所以2K下是不能使用该函数的。要么你就只能注入到目的进程然后再目的进程内用WM_PRINT抓了。