|
CPoint pt;
GetCursorPos(&pt);
CWnd* tWnd = WindowFromPoint(pt);
HWND hWnd = tWnd->GetSafeHwnd(); //窗口句柄
HDC hdc = ::GetDC(hWnd);
HDC memHDC = CreateCompatibleDC(hdc);
IImagingFactory *pImgFactory = NULL;
IImage *pImage = NULL;
CoInitializeEx(NULL,COINIT_MULTITHREADED);//初始化
if (m_NavRefresh || m_currentPick == 0)//图片
{
CoCreateInstance(CLSID_ImagingFactory,NULL,CLSCTX_INPROC_SERVER,IID_IImagingFactory,
(void **)&pImgFactory); //创建COM组件
pImgFactory->CreateImageFromFile(L"\\Storage Card\\imgBrowsedown1.png",&pImage);//读取图片信息
// memHDC = CreateCompatibleDC(hdc);//关联两个DC
// int width= rect[0].right -rect[0].left,heigth = rect[0].top-rect[0].bottom;
HBITMAP hBitmap = CreateCompatibleBitmap(hdc, m_rect[0].Width(),m_rect[0].Height());//在缓冲中建立BITMAP
SelectObject(memHDC, hBitmap);
BitBlt(memHDC, 0, 0, m_rect[0].Width(),m_rect[0].Height(), hdc, m_rect[0].TopLeft().x, m_rect[0].TopLeft().y, SRCCOPY);//背景提前载入
pImage-> Draw(memHDC, CRect(0,0,87,90),NULL);//
BitBlt( hdc,m_rect[0].TopLeft().x, m_rect[0].TopLeft().y, m_rect[0].Width(),
m_rect[0].Height(),memHDC, 0, 0, SRCCOPY);
// ShowPic(hdc, _T("\\Storage Card\\imgBrowseup1.png"),m_rect[0]);
} |
|