Display image data based on the MFC control static. add getdlgitem (idc_my_pic)-> modifystyle (ss_typemask, ss_ownerdraw) to oninitdialog; 2. add the following to the butto button to display the void cdlgpicdlg: ontest () {// todo: add your command handler code here cfiledialog filedlg (true, null, null, ofn_allowmultiselect, _ T ("picture files (*. BMP *. ICO *. JPG) | * BMP ;*. ICO; * JPG | all files (*. *) | *. * | "), afxgetmainwnd (); cstring pathname; If (filedlg. domod Al () = idok) {position MPOs = filedlg. getstartposition (); While (MPOs! = NULL) {pathname = filedlg. getnextpathname (MPOs); If (m_pict.loadpicture (pathname. getbuffer (pathname. getlength () {// prevents transparent images and eliminates the existing image information cpaintdc (this); // device context for painting crect RC; getdlgitem (idc_my_pic) -> getwindowrect (& rc); DC. fillsolidrect (RC, RGB (0, 0, 0); invalidate () ;}}} 3. add the notify message ing function to the parent window to draw the control void cdlgpicdlg: ondrawitem (INT nidctl, lpdrawitemstruct detail) in the ondrawitem (INT nidctl, lpdrawitemstruct detail) Message ing function in: add your message handler code here and/or call default if (nidctl = idc_my_pic) {If (m_pict.m_pic) {rect; trace ("-- hell -- Test ---"); hwnd =: getdlgitem (this-> getsafehwnd (), idc_my_pic); HDC =:: getdc (: getdlgitem (this-> getsafehwnd (), idc_my_pic )); // get the DC for the cpicture box: getclientrect (: getdlgitem (this-> getsafehwnd (), idc_my_pic), & rect ); // get dimensions of IT m_pict.drawpicture (HDC, 0, 0, rect. right-rect. left, rect. bottom-rect. top);: releasedc (: getdlgitem (this-> getsafehwnd (), idc_my_pic), HDC) ;}} cdialog: ondrawitem (nidctl, lpdrawitemstruct);} conclusion: if the image needs to be displayed in static mode and the painting in onpaint is ineffective, the painting should be as follows: 1) Add the ss_ownerdraw attribute getdlgitem (idc_my_pic)-> modifystyle (ss_typemask, ss_ownerdraw) to the static ); 2) Add the on_wm_drawitem message ing function to the parent window. 3) Draw controls in the ondrawitem (INT nidctl, lpdrawitemstruct) Message struing function, for example: the following is a blue background void cmydlg: ondrawitem (INT nidctl, lpdrawitemstruct) {If (nidctl = idc_static_draw) {CDC * PDC = CDC :: fromhandle (lpdrawitemstruct-> HDC); PDC-> fillsolidrect (10, 10, lpdrawitemstruct-> rcitem. right-20, lpdrawitemstruct-> rcitem. bottom-20, RGB (0, 0,255); return;} cdialog: ondrawitem (nidctl, lpdrawitemstruct);} You can also inherit a new class from cstatic, then add wm_paint message processing and draw the following image in onpaint: Class cmystatic: Public cstatic {... afx_msg void onpaint () ;}; void cmystatic: onpaint () {cpaintdc DC (this); // device context for painting crect RC; getclientrect (RC); DC. fillsolidrect (RC, RGB (0, 0,255 ));}