|
-
April 23rd, 2006, 11:17 PM
#1
what s the problem with my code?
hi guys:
everbody knows how to displaying a bitmap to screen.we just need a memory dc and a display dc. and i try to simulate this on OnPaint and it failed to work. anyone knows why? plz . ty so much
CXXX::OnPaint()
{
CPaintDC dc(this);//default code
CDC memdc;
memdc.CreateCompatibleDC(&dc);
memdc.TextOut(0,0,"hello");
dc.BitBlt(0,0,100,30,&memdc,0,0,SRCCOPY);
}
have a nice day
-
April 24th, 2006, 12:38 AM
#2
Re: what s the problem with my code?
CPaintDC dc(this);//default code
CDC memdc;
CBitmap bmp;
CRect rc;
GetClientRect(&rc);
bmp.CreateCompatibleBitmap(&dc,rc.Width(),rc.Height());
memdc.CreateCompatibleDC(&dc);
memdc.SelectObject(&bmp);
memdc.FillRect(&rc,&CBrush(RGB(255,255,255)));
memdc.TextOut(0,0,"hello");
dc.BitBlt(0,0,100,30,&memdc,0,0,SRCCOPY);
-
April 24th, 2006, 12:43 AM
#3
Re: what s the problem with my code?
PS:if necessary, you can store the the Old bitmap object of the memdc when selecting the new bitmap:
CBitmap *pOldBmp = memdc.SelectObject(&bmp);
then at the last steps you can recover it:
memdc.SelectObject(pOldBmp);
-
April 24th, 2006, 11:00 AM
#4
Re: what s the problem with my code?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|