• Advertisement

Archived

This topic is now archived and is closed to further replies.

PaintDC problem

This topic is 6210 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m trying to draw an array of 2D tiles (bitmaps) using Win GDI CPaintDC and CDC. Each tile can draw itself outsite the OnPaint message, but are called from OnPaint(), and are drawn in a loop. The actual blitting does not occur in OnPaint(). I''m using BitBlt() to draw the bitmaps. Only the first tile draws itself, and although the others appear to draw themselves, nothing appears on screen for them. Any ideas?

Share this post


Link to post
Share on other sites
Advertisement
You may want to use InvalidRect() function, to force a repaint,
But I not sure if it''s going to work.

You can check www.codeguru.com , they have a lot of MFC samples and related stuff.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I don''t really get what you are saying but here''s my version of drawing tile in loop outside OnPaint().

  
// assume tile size are 40x40

// assume you define CDC tile[number_of_tiles] in CTestView.h

void CTestView::OnLButtonUp()
{
CClientDC this_dc(this);
int k,x;

for (k=0,x=0; k<number_of_tiles; k++,x+=40) {
this_dc.BitBlt(x,0,40,40,&tile[k],0,0,SRCCOPY);
}
}

Share this post


Link to post
Share on other sites

  • Advertisement