dcsimg

A quick method to load a bitmap file in a CBitmap

WEBINAR:
On-Demand

Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame


A Quicker way to load *.BMP files into a CBitmap Object

  1. Create your own CBitmap derived class (say, CMyBitmap)
  2. add a "load from bitmap" method as listed below

BOOL CMyBitmap::LoadBitmap(LPCTSTR szFilename) 
{ 
	ASSERT(szFilename);
	DeleteObject();

	HBITMAP hBitmap = NULL; 
	hBitmap = (HBITMAP)LoadImage(NULL, szFilename, IMAGE_BITMAP, 0, 0, 
		LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE); 
	return Attach(hBitmap); 
}



Comments

  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date