Cbitmap::loadbitmap problems

Source: Internet
Author: User

BOOL LoadBitmap (LPCTSTR lpszresourcename) bool LoadBitmap (UNIT nIDResource)

Loads an anchor map by specifying a resource name or resource ID. However, the resource specified by the program cannot be directly identified by the path and name of the bitmap. If the function call succeeds, it returns a value other than 0, otherwise 0

Cbitmap::loadbitmap () cannot be opened as a file, the reason is not known, although provided LPCTSTR lpszResourceName (Host Note: This parameter is the DLL or EXE resource name, not the file name), gives another method, is also commonly used. Take a look at the following code: CBitmap bmp; Hbitmap hbmp;//bitmap handle hbmp= (HBITMAP):: LoadImage (NULL, "bitmap1.bmp", image_bitmap,0,0, Lr_loadfromfile);// Open bitmap resource bmp from File bitmap1.bmp. Attach (hbmp);//Binding

To display bitmaps:

CDC dcmemory; cbitmap* poldbmp; Dcmemory.createcompatibledc (PDC); Poldbmp = Dcmemory.selectobject (bitmap); Pdc->bitblt (0,0,500,500,&dcmemory,0, 0,srccopy); Dcmemory.selectobject (poldbmp);

For a bitmap resource that the program loads well:

CBitmap bitmap; CDC dcmemory; Bitmap. LoadBitmap (IDB_BITMAP1); Dcmemory.createcompatibledc (PDC); Dcmemory.selectobject (&BITMAP); Pdc->bitblt (0,0,699,919,&dcmemory,0,0,srccopy);

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.