1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
//
//
//
QPixmap EEmbedObject::ObjectImage()
{
QPixmap p;
SIZE picSize;
HDC dc;
RECT r;
RECTL rec;
UINT oldAlign;
long hr;
HDC tmpDC = GetDC((HWND) winId());
HDC memDC = CreateCompatibleDC(tmpDC);
HBITMAP hBmp = CreateCompatibleBitmap(tmpDC, width(), height());
HBITMAP oldBmp = (HBITMAP)SelectObject(memDC, hBmp);
SetRect(&r, 0, 0, width(), height());
rec.top = r.top;
rec.left = r.left;
rec.bottom = r.bottom;
rec.right = r.right;
if (m_pIViewObject == NULL)
hr = m_pObj->QueryInterface(IID_IViewObject, (void **) &m_pIViewObject);
//SetBkColor(memDC, RGB(255, 255, 255));
//SetTextColor(memDC, RGB(0, 0, 0));
//SetBkMode(memDC, OPAQUE);
oldAlign = SetTextAlign(memDC, TA_TOP);
hr = m_pIViewObject->Draw(DVASPECT_CONTENT, -1, NULL, NULL, NULL, memDC, &rec, NULL, NULL, 0);
//hr = OleDraw(m_pObj, DVASPECT_CONTENT, memDC, &r);
SetTextAlign(memDC, oldAlign);
SelectObject(memDC, oldBmp);
// JSL - code to write out the BMP to a file, so I can see it before the conversion.
PBITMAPINFO pbi = CreateBitmapInfoStruct((HWND) gMainWindow->winId(), hBmp);
CreateBMPFile((HWND) gMainWindow->winId(), (LPTSTR) L"oleDrawBitmap.bmp", pbi, hBmp, tmpDC);
p = QtWin::fromHBITMAP(hBmp, QtWin::HBitmapAlpha);
p.save(QString("oleDrawPixmap.bmp"));
DeleteObject(hBmp);
DeleteDC(memDC);
ReleaseDC((HWND) winId(), tmpDC);
return(p);
}
|