need help painting bitmaps

I have a fuction that paints some bitmaps called paintbits(CPaintDC* pdc), which I call from my OnPaint() function like this:

void CSimuladorDlg::OnPaint()
{ CPaintDC dc(this);
paintBits(&dc);
....
}
I want a separate functions because I will be doing more stuff in there.
It works until I try to use the BitBtl funcion, my code is :


void CSimuladorDlg::paintBits(CPaintDC* pdc)
{ CBitmap bmpApagado;
CDC dcApagado;


bmpApagado.LoadBitmap(ID_APAGADO);
dcApagado.CreateCompatibleDC(pdc);
CBitmap *bmpPrevious1 = dcApagado.SelectObject(&bmpApagado);


int posX = 10;
int posY = 130;
int deltaX = 24;
int deltaY = 20;
int posX2= 0;
int posY2 = 0;

for( int i = (int) b.size(); i >= 0; i-- )
{ posX2 = posX + deltaX;
posY2 = posY + deltaY;

pdc::BitBlt(posX, posY, posX2, posY2, &dcApagado, 0, 0, SRCCOPY);


}
}

Last edited on
The parameters to the CDC::BitBlt function are
1
2
3
4
5
6
7
8
9
10
BOOL BitBlt(
   int x,
   int y,
   int nWidth, // the width (in logical units) of the destination rectangle and source bitmap.
   int nHeight, // the height (in logical units) of the destination rectangle and source bitmap.
   CDC* pSrcDC,
   int xSrc,
   int ySrc,
   DWORD dwRop 
);


Looks like you are passing 0 (zero) for the width and the height - which will almost certainly do
nothing.

It should also be pdc->BitBlt..... not pdc::BitBlt
Last edited on

I had accidentally delete the for sentence when I originally wrote this post, I've already corrected this, and after changing to

pdc->BitBlt everything works fine. Thank you
Topic archived. No new replies allowed.