Add a cstatic control in the caboutdlg dialog box with the ID idc_static_aboutbox_avatar. Use the following method to display the image. Note that the image display operation must be performed in the onpaint () message processing function, otherwise, the image cannot be displayed normally (for details, see the notes ). However, when a large image is displayed, the image is compressed due to a large degree of scaling, causing serious distortion. I do not know how to solve this problem.
Bool caboutdlg: oninitdialog () <br/>{< br/> cdialog: oninitdialog (); <br/> m_pstcavatar = (cstatic *) getdlgitem (batch ); <br/> m_pstcavatar-> getclientrect (& m_rectstc); <br/> return true; <br/>}</P> <p> void caboutdlg: onpaint () <br/> {<br/> cpaintdc (this); // device context for painting <br/> showimage (); <br/>/* if it is placed in oninitdialog () the function cannot display the image normally, because after the oninitdialog () function shows the image, Windows sends a wm_paint message to draw the caboutdlg dialog box. When the caboutdlg intercepts the message and calls onpaint () this dialog box is re-painted when the message processing function is used, so the image is refreshed. Therefore, you can only call showimage () in the onpaint () function () function display image */<br/>}</P> <p> void caboutdlg: showimage () <br/>{< br/> CDC * PDC = m_pstcavatar-> getdc (); <br/> CDC memdc; <br/> memdc. createcompatibledc (PDC); <br/> cbitmap * avatarbmp = new cbitmap (); <br/> cbitmap * oldbmp; <br/> bitmap bminfo; <br/> avatarbmp-> loadbitmap (idb_avatar); <br/> avatarbmp-> GetObject (sizeof (bminfo), & bminfo); <br/> oldbmp = memdc. selectObject (avatarbmp); <br/> PDC-> stretchblt (, m_rectstc.width (), m_rectstc.height (), & memdc, bminfo. bmwidth, bminfo. bmheight, srccopy); <br/> If (oldbmp) <br/>{< br/> memdc. selectObject (oldbmp); <br/>}< br/> releasedc (PDC); <br/>}