I have a problem to SelectObject of Bitmap into memery DC. My code is like, Code: HINSTANCE hinstOriginal; hinstOriginal = ::AfxGetResourceHandle(); ::AfxSetResourceHandle(g_hResInstance); CDC mem; CBitmap *oldBmp; CBitmap temp; BOOL B = temp.LoadBitmap(id); //id is resource id BITMAP BitMap; temp.GetBitmap(&BitMap); mem.CreateCompatibleDC( pPrintDC ); // a printer DC mem.SetMapMode (pPrintDC->GetMapMode ()); oldBmp = mem.SelectObject(&temp); // this call returns 0 on some PCs! CPoint size; size.x = BitMap.bmWidth; size.y = BitMap.bmHeight; mem.DPtoLP(&size); BOOL bret = pGDoc->m_pDC->StretchBlt(m_iX, m_iY*-1, m_iWidth, m_iHeight*-1, &mem, 0, 0, size.x, size.y, SRCCOPY); This code works on same PC, but not on others, SelectObject returns 0; Please help. Thank you very much. hlin_do henryzlin@hotmail.com
I see a definite problem here BITMAP BitMap; Variable is declared but not initialized temp.GetBitmap(&BitMap); GetBitmap should not work to the variable which is not initilaized oldBmp = mem.SelectObject(&temp); Obvious reason is it should fail On some systems the garbage for BitMap may not be NULL.
I think I know how to make it work now. Basicly, I need to load as DIB instead bitmap. Thanks anyway! hlin_do