Cause: The drawing function is required in the cscrollview, and the size of the drawing exceeds the actual size of the screen. In order to solve the problem of flashing, the method of dual-bundle drawing (drawing the image first, then paste into the screen), however it is pasted into the screen) When dragging the scroll bar, there is a problem with the screen overlap. The following is a specific solution; ideas: first in the onDraw function, the following is a simple step; 1, use the CreateComparableDC function to generate a memory DC
2. Create a memory Bitmap using CreateCompaPleBitMap, the size of the image is used when the ScrollView size (you can use the GetTotalsize function to get the size of the view) 3, the memory DC loads the memory memory Bitmap 4, and then the memory DC can use the drawing function to draw 5, The current client area DC uses the Bitblt function to paste the bitmap in the memory DC to the customer area corresponding code as follows:
Void CscrollView :: Ondraw (CDC * PDC)
{
CDC * m_pmemorydc = new CDC ();
CBitmap * m_pbitmap = new cbitmap ();
CSIZE SIZETOTAL = GetTotalsize ();
MemoryDC-> CreateCompatiPLEDC (PDC);
M_Pbitmap-> CreateCompATIBLEBITMAP (PDC, SizetAl.cx, sizetotal.cy);
CBITMAP * POLDBMP = m_pMemorydc-> selectObject (m_pbitmap);
// 省 省 画 部分 部分, you can use Lineto, Textout and other drawing functions
PDC-> Bitblt (0,0, sizetotal.cx, sizetotal.cy, m_pmemorydc, 0,0, srcopy);
// Release the resource m_pmemorydc-> selectObject (PoldBMP);
m_pbitmap-> deleteObject ();
m_pMemorydc-> deletedc ();
Delete m_pmemorydc;
Delete m_pbitmap;
}
Then change the oneRaseBkgn function, set the return value to true, the code is as follows:
Bool CscrollView :: OneRaseBkGnd (CDC * PDC)
{
Return True;
}
in conclusion:
Advantages, when using the view size, do not need to consider the actual screen size, and do not need to consider the position of the scroll bar, because each time you draw the size of the entire view, and paste as the size of the entire view;
Disadvantages: Every time you draw, you have to draw the entire map, waste resources; note: When using dual cache, you must use the setWindoworg, SetVieworg, etc.