المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : some confuse about compatible DC and compatible Bitmap



C++ Programming
08-08-2009, 07:53 AM
Recently,I'm learning how to make custom UI,by using BitBlt() put some bitmap to DC.When comes to 'Compatible DC' and 'Compatible Bitmap',i'm confused about codes as follows:

codes in function OnPaint():(VC++)
CDC memDC,tempDC;
CClientDC dc(this);
CBitmap memBmp;
CRect rcClient;

GetClientRect( &rcClient );

memDC.CreateCompatibleDC( &dc );
tempDC.CreateCompatibleDC( &memDC );
memBmp.CreateCompatibleBitmap( &dc, rcClient.Width(), rcClient.Height() );

tempDC.SelectObject( &m_bmp ); //(assume the m_bmp is a initial CBitmap ojbect)

memDC.SelectOjbect( &memBmp ); //First
memDC.BitBlt( p1,p2,..., &tempDc,...., SRCCOPY ); //Second

dc.BitBlt( p1,p2,......, &memDC,....., SRCCOPY ); //Third

//code end

I know how to use these codes but i don't why it does.

1.From codes i marked "First" and "Senond",I wonder if SelectObject( &memBmp ) only gives memDC's data member a value and BitBlt gives memDC something to display? if this why to use SelectObject()?

2.Codes marked "second" and "third". From "second" codes it use &tempDC as its parameter, but tempDC just only used SelectObject( &m_bmp ),i means it doesn't use BitBlt to disply somethig ,why it can be "BitBlt"
to memDC?
From "third" codes,dc's BitBlt use memDC as its parameter,and it executed BitBlt before.So I think this code is correct( but i know all these is correct haha...).
So i wonder,does the process "BitBlt" copys the SrcDC's disply things to DestDC,or copys the SrcDC's Bitmap object(been valued in SelectObject() )to DestDc to display?

My mother ******** is not English,and my english level is very lower(Sorry).I don't know if someone can understand my means.
I hope all of you gives me some advice,thank you!


this is the first time i asked question in this haha...