Advertisement

Device Contexts and CBitmap

Started by April 23, 2000 08:38 PM
-1 comments, last by Zipster 24 years, 7 months ago
Hey, its me again, still working on that same program, only a different problem. What I have here is a CBitmap (lets call it m_bBitmap), and a CObList name m_list. What im trying to do is take m_bBitmap and divide it into smaller CBitmaps, and place all the smaller CBitmap''s into the CObList. This is my code:
CDC workDC;
workDC.CreateCompatibleDC(&dc);
workDC.SelectPalette(&m_pPalette, false);
memDC.SelectObject(m_bBitmap);
int x , y , z;
z=1;
for(y = 0; y < m_nBitmapHeight; y++)
{
   for(x = 0; x < m_nBitmapWidth; x++)
        {
	    CBitmap *bWork = (CBitmap *)new CBitmap;
					            bWork->CreateCompatibleBitmap(&dc, m_nTileWidth, m_nTileHeight);
	    CBitmap *old = workDC.SelectObject(bWork);
	    workDC.BitBlt(0,0, m_nTileWidth, m_nTileHeight, &memDC, x*m_nTileWidth, y*m_nTileHeight, SRCCOPY);
					workDC.SelectObject(old);
					TemplateMain.m_listGraphics.AddTail(bWork);
					delete bWork;
				}
			}
 
Above, memDC contains the CBitmap i want to cut-up, and dc is a divide context i created using
CClient dc(NULL); 
My entire problem is that after i do the "cuting up", i try to draw all the little CBitmap''s into a CStatic, but all the CBitmap''s just contain grey. I know i loaded the bmp file right becuase when i draw the big CBitmap, it works, but it won''t draw any of the smaller CBitmaps. Here''s the code for that part:
CString temp;
	CBitmap* m_bBitmap;
	m_cCombo.GetLBText(m_cCombo.GetCurSel(), temp);
	m_cCombo.SetWindowText(temp);
	if(pDoc->m_bTemplateLoaded)
	{
		pDoc->TemplateMain.m_pos = pDoc->TemplateMain.m_listGraphics.FindIndex(m_cCombo.GetCurSel());
		m_bBitmap = (CBitmap *)pDoc->TemplateMain.m_listGraphics.GetAt(pDoc->TemplateMain.m_pos);

		m_cPreview.SetBitmap((HBITMAP)m_bBitmap);
	} 
m_cPreview is the CStatic, and m_cCombo is a combo box used to reference the CObList. What am i doing wrong?

This topic is closed to new replies.

Advertisement