void Cdlglogon::onpaint () {CPAINTDC DC (this),//device context for painting//TODO: Add Message Handler code here//Do not call for drawing messages Cdialo
Gex::onpaint () CString strpath;
strpath + = "d:\\res\\logpicture1.jpg";
CFile M_file (Strpath,cfile::moderead); Gets the file length DWORD M_filelen = M_file.
GetLength ();
Allocate space on the heap hglobal M_hglobal = GlobalAlloc (Gmem_moveable,m_filelen);
LPVOID pvdata = NULL;
Locks the heap space and gets a pointer to the heap space pvdata = GlobalLock (M_hglobal); Reads the file data into the heap m_file.
Read (Pvdata,m_filelen);
istream* M_stream;
GlobalUnlock (M_hglobal);
Creates a Stream object CreateStreamOnHGlobal (M_hglobal,true,&m_stream) in the heap;
Use the stream to load the image oleloadpicture (M_stream,m_filelen,true,iid_ipicture, (lpvoid*) &m_picture);
M_stream->release ();
M_picture->get_width (&m_width);//wide-height, mm_himetric mode, unit 0.01 mm m_picture->get_height (&m_height);
M_isshow = TRUE; M_file.
Close ();
if (m_isshow==true) {CRect rect;
GetClientRect (rect);
int NW, NH; NW = (int) (rect.
Width ()); NH = (int) (rect.
Height ()); M_Picture->render (Dc,0,0,nw,nh,0,m_height,m_width,-m_height,&rect);
} cdialogex::onpaint (); }
Transferred from: Http://blog.csdn.net/lili893628843/article/details/8200906?utm_source=jiancool