002
22.10.2006, 15:14 Uhr
xXx
Devil
|
Hmm k
C++: |
bool dataPictureCtrl::LoadImage(LPCBYTE lpbyData, unsigned long dwLen) { if (lpbyData == NULL) return false;
if (m_pImage != NULL) { delete m_pImage; m_pImage = NULL; }
LPVOID lpData = NULL; HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, dwLen);
if (hGlobal == NULL) return false;
lpData = GlobalLock(hGlobal);
if (lpData == NULL) { GlobalUnlock(hGlobal); return false; }
memcpy(lpData, lpbyData, dwLen);
GlobalUnlock(hGlobal);
LPSTREAM lpStream = NULL;
if (FAILED(CreateStreamOnHGlobal(hGlobal, TRUE, &lpStream))) { if (lpStream != NULL) lpStream->Release();
return false; }
if (lpStream == NULL) return false;
m_pImage = Gdiplus::Image::FromStream(lpStream); if (m_pImage == NULL || m_pImage->GetLastStatus() != Gdiplus::Ok) { lpStream->Release(); return false; }
lpStream->Release();
InvalidateRect(NULL);
return true; }
|
und dann zeichnen
C++: |
BOOL dataPictureCtrl::OnEraseBkgnd(CDC* pDC) { if (IsWindowVisible() == TRUE && m_pImage != NULL/* && IsWindowEnabled() == TRUE*/) { CRect rcClient; GetClientRect(&rcClient);
Gdiplus::Graphics graphics(pDC->GetSafeHdc()); graphics.DrawImage(m_pImage, Gdiplus::Rect(rcClient.left, rcClient.top, rcClient.Width(), rcClient.Height())); Gdiplus::Pen penBorder(Gdiplus::Color(255, 255, 0, 255)); graphics.DrawRectangle(&penBorder, Gdiplus::Rect(rcClient.left, rcClient.top, rcClient.Width() - 1, rcClient.Height() - 1)); }
return CStatic::OnEraseBkgnd(pDC); }
|
Aber das will noch nicht so ganz ... evt. liegts auch einfach daran, das die EraseBackground Funktion net mehr aufgerufen wird... |