Void InitBackgroundImage (pDC) CDC *
{
If (m_nModMove==VIEW_MOD_MOVE)
return;
DestroyBackgroundImage ();
CRect rectClient;
GetClientRect (& amp; RectClient);
The CDC dcBkgnd;
M_dcMemory. CreateCompatibleDC (pDC);
ASSERT (m_dcMemory GetSafeHdc ());
M_bitmapTemp. CreateCompatibleBitmap (pDC, m_nScreenWidth m_nScreenHeight);
ASSERT (m_bitmapTemp GetSafeHandle ());
M_pOldBitmap=m_dcMemory. SelectObject (& amp; M_bitmapTemp);
M_dcMemory. FillSolidRect (0, 0, m_nScreenWidth m_nScreenHeight, VIEWCOLOR);
DrawBox (& amp; M_dcMemory);//draw a custom background picture
}
Void OnPaint ()
{
InitBackgroundImage (& amp; Dc);//back to the background, the background does not change when not draw
The CDC dcMemory;
DcMemory. CreateCompatibleDC (& amp; M_dcMemory);
CBitmap BMP.
BMP. CreateCompatibleBitmap (& amp; M_dcMemory m_nScreenWidth, m_nScreenHeight);
CBitmap * pOldBitmap=dcMemory. SelectObject (& amp; BMP);
DcMemory. SetBkMode (TRANSPARENT);
DcMemory. BitBlt (0, 0, m_nScreenWidth m_nScreenHeight, & amp; M_dcMemory, 0, 0, SRCCOPY);//the CDC copy
DrawMoveingBox (& amp; DcMemory);//draw mobile rectangle
Dc. BitBlt (0, 0, m_nScreenWidth m_nScreenHeight, & amp; DcMemory, 0, 0, SRCCOPY);//draw the image to the main DC
DcMemory. SelectObject (pOldBitmap);
DcMemory. DeleteDC ();
BMP. DeleteObject ();
}
As shown in the code is m_dcMemory member variables, generated in order to save the background in the InitBackgroundImage function, need not frequent painting background, only need to move the rectangle in the picture on background
I think this drawing should be quickly in theory, but actual testing found that such drawing should also will be very card in the rectangular
CodePudding user response:
DrawMoveingBox (& amp; DcMemory);//draw mobile rectangle
The code
CodePudding user response:
Don't needInitBackgroundImage (& amp; Dc);//back to the background, the background does not change without drawing
CodePudding user response:
DcMemory made class variables and the corresponding bitmap can alsoBitBlt background to dcMemory
Then draw
BitBlt to the target DC
For those operations in DrawMoveingBox?
CodePudding user response: