indiocolifa
July 26th, 2004, 04:55 PM
My problem is that I want to draw some ownerdrawn controls on a GDI+ graphics surface.
My approach is:
1. I've declared a global object as:
extern Gdiplus::Bitmap *pBmpOdElem;
2. I setup an empty bitmap with:
void createGdiplusObj(void)
{
pBmpOdElem = new Bitmap(50,50,PixelFormatDontCare);
}
3. I try to draw onto the bitmap using the pBmpOdElem pointer:
BOOL OwnDrawProc (WPARAM wparam, LPARAM lparam)
{
HBITMAP hBitmap = 0;
LPDRAWITEMSTRUCT lpDrawItem = (LPDRAWITEMSTRUCT)lparam;
int x = lpDrawItem->rcItem.top;
int y = lpDrawItem->rcItem.left;
Graphics gr(lpDrawItem->hDC);
UINT uiSelect = lpDrawItem->itemState & ODS_SELECTED;
...
pBmpOdElem->FromHBITMAP(hBitmap, NULL);
gr.DrawImage (pBmpOdElem, x, y, pBmpOdElem->GetWidth(), pBmpOdElem->GetHeight());
}
and nothings happens...
My previous approach to the problem was creating a Bitmap object in the ownerdrawn procedure and draw it accordingly. This worked but I dont want to create a Bitmap object every time the painting routine gets called... it's not efficient.
Any help with managing those GDI+ ptrs?
thank you.
Hernan
My approach is:
1. I've declared a global object as:
extern Gdiplus::Bitmap *pBmpOdElem;
2. I setup an empty bitmap with:
void createGdiplusObj(void)
{
pBmpOdElem = new Bitmap(50,50,PixelFormatDontCare);
}
3. I try to draw onto the bitmap using the pBmpOdElem pointer:
BOOL OwnDrawProc (WPARAM wparam, LPARAM lparam)
{
HBITMAP hBitmap = 0;
LPDRAWITEMSTRUCT lpDrawItem = (LPDRAWITEMSTRUCT)lparam;
int x = lpDrawItem->rcItem.top;
int y = lpDrawItem->rcItem.left;
Graphics gr(lpDrawItem->hDC);
UINT uiSelect = lpDrawItem->itemState & ODS_SELECTED;
...
pBmpOdElem->FromHBITMAP(hBitmap, NULL);
gr.DrawImage (pBmpOdElem, x, y, pBmpOdElem->GetWidth(), pBmpOdElem->GetHeight());
}
and nothings happens...
My previous approach to the problem was creating a Bitmap object in the ownerdrawn procedure and draw it accordingly. This worked but I dont want to create a Bitmap object every time the painting routine gets called... it's not efficient.
Any help with managing those GDI+ ptrs?
thank you.
Hernan