ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

A question about acdbGetPreviewBitmapFromDwg on recycling Storage

0 REPLIES 0
Reply
Message 1 of 1
onedey
306 Views, 0 Replies

A question about acdbGetPreviewBitmapFromDwg on recycling Storage

I use acdbGetPreviewBitmapFromDwg to get a dwg file's preview bitmap and draw the bitmap on Image Listbox Control ,
but Listbox Control keeps in with executing Onpaint when scrolling, I found the storage is not recyled. here is my code and I
have executed DeleteObject(hBitmap), DeleteObject(hPalette);

Can you help to solve the problem!

HBITMAP hBitmap = NULL;
HPALETTE hPalette = NULL;
acdbGetPreviewBitmapFromDwg(item.szFilename, &hBitmap, &hPalette);

if(hBitmap!=NULL && hPalette!=NULL)
{
CPalette* oldPal = pDC->SelectPalette(CPalette::FromHandle(hPalette), TRUE);
pDC->RealizePalette();

CBitmap bitmap;
bitmap.Attach(hBitmap);

BITMAP bm;
bitmap.GetObject(sizeof(bm), (LPVOID)&bm);

CDC dcMem;
dcMem.CreateCompatibleDC(pDC);

CBitmap *pOldBitmap = dcMem.SelectObject(&bitmap);

//pDC->StretchBlt(rectTemp.left, rectTemp.top, (int)(bm.bmWidth*ds),(int)(bm.bmHeight*ds), &dcMem, 0, 0,bm.bmWidth, bm.bmHeight,SRCCOPY);

dcMem.SelectObject(pOldBitmap);

pDC->SelectPalette(oldPal,TRUE );
pDC->RealizePalette();

bitmap.DeleteObject();
DeleteObject(hBitmap);
DeleteObject(hPalette);
}
0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost