Add the code to the onpaint () function in the dialog box:
Take my code as an example:
// Graphics
// Use graphics. drawimage
Void userlist: onpaint ()
{
Cpaintdc DC (this); // device context for painting
// Graphics. drawimage
Crect rect;
Getclientrect (& rect );
Graphics graphics (DC. m_hdc );
// Load the PNG Image
Bitmap background (L ". \ userlist \ classlist_top.png ");
Graphics. drawimage (& background, 0, 0, rect. Width (), rect. Height ());
Cdialog: onpaint ();
}
Void userlist: onpaint ()
{
Cpaintdc DC (this); // device context for painting
// Load the PNG Image
Bitmap background (L ". \ userlist \ classlist_top.png ");
// Second Method of Drawing bitblt Original Image
Crect RC;
CDC memdc;
Cbitmap;
Cbitmap * poldbmp = NULL;
Hbitmap;
CDC * PDC = getdc ();
// Bitmap to hbitmap
// Hbitmap to cbitmap *
Background. gethbitmap (color (0, 0), & hbitmap); // bitmap to hbitmap
Cbitmap * cbitmap = cbitmap: fromhandle (hbitmap); // hbitmap to cbitmap *
// Display the image
Memdc. createcompatibledc (PDC );
Poldbmp = memdc. SelectObject (cbitmap );
Getclientrect (& rc );
DC. bitblt (0, 0, rect. Width (), rect. Height (), & memdc, 0, 0, srccopy );
// Releasedc
Memdc. SelectObject (poldbmp );
Memdc. deletedc ();
Cbitmap-> deleteobject ();
Cdialog: onpaint ();
}
Void userlist: onpaint ()
{
Cpaintdc DC (this); // device context for painting
// Load the PNG Image
Bitmap background (L ". \ userlist \ classlist_top.png ");
// Method 3 for drawing stretchblt tiled Images
Crect RC;
CDC memdc;
Cbitmap;
Cbitmap * poldbmp = NULL;
Hbitmap;
CDC * PDC = getdc ();
// Bitmap to hbitmap
// Hbitmap to cbitmap *
Background. gethbitmap (color (0, 0), & hbitmap); // bitmap to hbitmap
Cbitmap * cbitmap = cbitmap: fromhandle (hbitmap); // hbitmap to cbitmap *
// Display the image
Memdc. createcompatibledc (PDC );
Poldbmp = memdc. SelectObject (cbitmap );
Getclientrect (& rc );
DC. stretchblt (0, 0, rect. Width (), rect. Height (), & memdc, 0, background. getwidth (), Background. getheight (), srccopy );
// Releasedc
Memdc. SelectObject (poldbmp );
Memdc. deletedc ();
Cbitmap-> deleteobject ();
Cdialog: onpaint ();
}