Making my Breakout Game in MFC. I store the bitmap info into a CDC
object (Device Context Object), but since there will be different bitmaps for each block, I store the same overwritten CDC m_blockDC
into a std::vector<CDC> m_blockStates
and since I have five block types I store the before mentioned vector into a std::vector<std::vector<CDC>>
so I can access each block state bitmap info using a enum BLOCKPROPS
and their hit property which is vinculated with the index; thus, I will be accessing each block state with m_blockStates[BLOCKTYPE][CBlock.GetHits()]
When I try to run the program the error 'CDC::CDC(const CDC &)': attempting to reference a deleted function
appears.
This is how I store the m_blockDC
into the bidimensional vector:
void CCreateWindow::LoadBlock(std::vector<LPCWSTR> FileMap, BLOCKPROP BlockProperty)
{
for (int i = 0; i < FileMap.size(); i++)
{
HANDLE blockBitmap = LoadImage(0, FileMap[i], IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); //(Instance, FileSrc, Type, PartX, PartY, Process)
m_blockCBMP.Attach(reinterpret_cast<HBITMAP>(blockBitmap));
pDC = this->GetDC();
m_blockDC.CreateCompatibleDC(pDC);
switch (BlockProperty)
{
case TUFF:
m_blockStateArray[TUFF].push_back(m_blockDC);
break;
case STRD:
m_blockStateArray[STRD].push_back(m_blockDC);
break;
case WEAK:
m_blockStateArray[WEAK].push_back(m_blockDC);
break;
case SPCL:
m_blockStateArray[SPCL].push_back(m_blockDC);
break;
case INDS:
m_blockStateArray[INDS].push_back(m_blockDC);
break;
default:
break;
}
}
//Get BitmapSize
m_blockDC.SelectObject(&m_blockCBMP);
m_blockCBMP.GetBitmap(&m_blockBMP);
}
This code is used in the OnInitDialog()
of CCreateWindow.cpp
and the function PaintBlock()
within OnTimer()
will be used to paint the blocks, or at least that's how it is suppossed to be.