Something simple, hey
- Void ctestdlg: onpaint ()
- {
- If (isiconic ())
- {
- Cpaintdc DC (this); // device context used for plotting
- Sendmessage (wm_iconerasebkgnd, reinterpret_cast <wparam> (DC. getsafehdc (), 0 );
- // Center the icon in the rectangle of the Workspace
- Int cxicon = getsystemmetrics (sm_cxicon );
- Int cyicon = getsystemmetrics (sm_cyicon );
- Crect rect;
- Getclientrect (& rect );
- Int x = (rect. Width ()-cxicon + 1)/2;
- Int y = (rect. Height ()-cyicon + 1)/2;
- // Draw the icon
- DC. drawicon (X, Y, m_hicon );
- }
- Else
- {
- Cpaintdc DC (this );
- Crect rect;
- Getclientrect (& rect); // obtain the customer's size
- CDC memdc;
- Cbitmap;
- Cbitmap * poldmembmp = NULL;
- Cbitmap. loadbitmap (idb_bitmap1 );
- Memdc. createcompatibledc (& DC); // create a device object context
- Poldmembmp = memdc. SelectObject (& cbitmap );
- Bitmap BMP;
- Cbitmap. getbitmap (& BMP );
- Setstretchbltmode (DC, stretch_halftone); // It is said that distortion can be reduced
- DC. stretchblt (0, 0, rect. Width (), rect. Height (), & memdc, 0, BMP. bmwidth, BMP. bmheight, srccopy );
- Memdc. SelectObject (poldmembmp );
- Cdialogex: onpaint ();
- }
- }
Is it easy?
Add a background image to the image in vs2010