I tried the following code on OnInitDialog() but nothing was shown.
m_staticLogo.SetBitmap(::LoadBitmap(NULL, MAKEINTRESOURCE(IDB_LOGO)));
where m_staticLogo is the static picture control and IDB_LOGO is the resource ID of the png file.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As you’ve discovered,
::LoadBitmap(and the newer::LoadImage) only deal with.bmps. By far the easiest solution is to convert your image to a.bmp.If the image has transparency, it can be converted into a 32-bit ARGB bitmap (here is a tool called AlphaConv that can convert it). Then load the image using the
CImageclassLoadFromResourcemethod. Pass theCImagetom_staticLogo.SetBitmap().But if you really need it to be a
.png, it can be done.Method 1 (the easier way): Load the
.pngfrom a file usingCImage::Load. Pass theCImagetom_staticLogo.SetBitmap().Method 2 (the harder way): Load the
.pngfrom a resource by loading the resource into a COMIStreamand usingCImage::Load. (NOTE:CImage::LoadFromResourcelooks tempting but will not work with a.pnggraphic). To get the resource into a COMIStream, see this Codeproject article. Note the article works withGdiplus::Bitmapbut the key part is how to create theIStream, which you should be able to adapt forCImage. Finally, pass theCImagetom_staticLogo.SetBitmap().Edit: Updated to use
CImage, which is easier thanGdiplus::Bitmap.