It does not work when you execute GDI + to fill the background in ondraw. I do not know why
Graphics graphics (PDC-> getsafehdc (); bitmap BMP (m_imgrec.width (), m_imgrec.height ()); // The memory bitmap graphics grbmp (& BMP); solidbrush backbrush (RGB (255,255,255); grbmp. fillrectangle (& backbrush, 0, 0, m_imgrec.width (), m_imgrec.height (); // initializes the memory bitmap background graphics. drawimage (& BMP, m_imgrec.left, m_imgrec.top, m_imgrec.width (), m_imgrec.height (); // The second step draws the memory bitmap of the same screen size to the screen.
The original intention of the program is to initialize the customer area to white, but after the execution, the customer area is transparent, not white, and the filling operation does not have any effect. I wonder if someone can know the reason.
If this is not the case, we can use GDI in combination with GDI +.
Create memdc and cbitmap resources, use memdc to fill directly, and then create the memory DC's GDI + object graphics grbmp (memdc. getsafehdc (); Use this object to draw a picture
CDC memdc; cbitmap bm; memdc. createcompatibledc (PDC); BM. createcompatiblebitmap (PDC, m_imgrec.width (), m_imgrec.height (); memdc. selectObject (& BM); memdc. fillrect (& m_imgrec, & m_backbrush); // fill in the background graphics grbmp (memdc. getsafehdc (); // create the memory DC's GDI + object grbmp. drawimage (m_pbmp, nwidth, nheight); // drawing PDC-> bitblt (, m_imgrec.width (), m_imgrec.height (), & memdc, srccopy); // The memory DC is drawn to the screen.