MFC uses JPG images to make dialog box backgrounds

Source: Internet
Author: User


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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.