Advertisement

Help me plz!

Started by April 24, 2000 03:11 PM
2 comments, last by Zipster 24 years, 7 months ago
I posted this message before, but you ppl seem to like flaming kieron_j on that dumb ass MP3 post rather than help me! . Here''s a duplicated. I changed the topic to get your attention : 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?
None of you "expert" programmers can solve this? What is the world coming to that no one knows MFC well enough? Well if you guyz don''t know, thats ok.... I didn''t expect you to know anyway .

Did that provoke you any?
Advertisement
A few things:
CBitmaps are screwy.
I can''t see anything wrong with your code the way it is, but I always run a trace on my code which usually makes the bug fall out.
I''m not sure that BitBlt will be happy about what you''re trying to make it do. Perhaps you should write to the smaller bitmaps manually.
Check all handles and contexts involved for invalid values.

g''luck.
-fel
~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~
I copy this code directly out of "Programming in MFC" by Microsoft press, and it said it would work. I NEED to use CBitmapso i can use the CStaic::SetBitmap function later on!

This topic is closed to new replies.

Advertisement