[C\C++32] - how do double buffering?

my image class have the hdcimage with imageweight, imageheight.
knowing these, i need return the HBITMAP. so i must do the double buffering:
1
2
3
4
5
6
7
8
operator HBITMAP()
    {
        HDC mdc = CreateCompatibleDC(NULL);
        HBITMAP mbmp =  CreateBitmap(imageweight,imageheight,1,32,NULL); // width, height, 1, bit_depth, NULL
        HBITMAP moldbmp = (HBITMAP)SelectObject(mdc,mbmp);
        BitBlt(mdc, 0, 0, imageweight, imageheight, hdcimage, 0, 0, SRCCOPY);
        return mbmp;
    }

but i get problems :(
1 - the image isn''t showed;
2 - theres a memory leak.
Topic archived. No new replies allowed.