Professional UI Solutions
Site Map   /  Register


Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » Image with transparent background on CExtButton Collapse All
Subject Author Date
Bart Kampers Feb 6, 2009 - 6:59 AM

Hello there,

I want to create a button that shows an image from a PNG file. The image has a transparent background but on the button it gets a white background.

Can I get a transparent bachground without overriding the OnPaint method?

Here’s my code:

  CExtButton* button = new CExtButton; 

  button->Create(pCaption, WS_VISIBLE | WS_CHILD, pRect, this, pID);

  CExtSkinBitmap bitmap;

  if (bitmap.LoadPNG_File(pIconFileName, true, false))


    CExtCmdIcon icon;

    icon.m_bmpNormal = bitmap;

    button->m_icon = icon;


Technical Support Feb 6, 2009 - 2:19 PM

The code snippet in your message is absolutely correct and the button should display the transparent image, but only of the loaded PNG image is really contain transparent pixels. If you are loading PNG image with white non-transparent pixels which you would like to make transparent, then you can make these pixels transparent using the CExtBitmap::AlphaColor() method. If you are sure your PNG file contains transparent pixels, then you can send it to us and we will check what’s wrong. Please note, simple raster image editors like MSPAINT.EXE does not support transparency nevertheless they often can save PNG images.