CButton with Bitmap Transparency
-
Hello, I have a CButton created dynamically with bitmap: CButton m_mybutton.Create(NULL,WS_CHILD|WS_VISIBLE|BS_OWNERDRAW,CRect(1,87,110,107),this, ID_BTNHEADBOOKMARK); m_mybutton.LoadBitmaps(IDB_LISTHBOOKMARK, IDB_LISTHBOOKMARK, IDB_LISTHBOOKMARK, IDB_LISTHBOOKMARK); The image have some area with Color RGB(255,0,255). I wanted those area with that color above to be transparent. How can I do it?:confused: Hope i could get a response ASAP (if possible ) Also im using EVC, you can try it Visual Studio and if works, i'll try it to EVC3.0. Thanks you very much.
-
Hello, I have a CButton created dynamically with bitmap: CButton m_mybutton.Create(NULL,WS_CHILD|WS_VISIBLE|BS_OWNERDRAW,CRect(1,87,110,107),this, ID_BTNHEADBOOKMARK); m_mybutton.LoadBitmaps(IDB_LISTHBOOKMARK, IDB_LISTHBOOKMARK, IDB_LISTHBOOKMARK, IDB_LISTHBOOKMARK); The image have some area with Color RGB(255,0,255). I wanted those area with that color above to be transparent. How can I do it?:confused: Hope i could get a response ASAP (if possible ) Also im using EVC, you can try it Visual Studio and if works, i'll try it to EVC3.0. Thanks you very much.
-
My suggestion: Derive a subclass from CButton, modify its style as owner-draw. Overwrite the DrawItem() and use TransparentBlt() to paint the bitmap by yourself. Lane
-
Lane, I understand how to override DrawItem by creating a class derived from CButton, however there no TransparentBlt API in EVC3.0. Anyway to do TransparentBlt?:( Thanks Lane
NewVCbie wrote: Anyway to do TransparentBlt? You can use the "True Mask" method. It is the method used by windows to draw icons. It involves creating a black and white mask bitmap that uses white as the transparent part and black as the opaque part. You can have a look at my article at http://www.codeproject.com/bitmap/pjaimage.asp[^] where I use the method to draw transparent bitmaps. Look at the
CPJAImage::DrawTransparent()
method. Google[^]
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04 "There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05 Within you lies the power for good - Use it!
-
Lane, I understand how to override DrawItem by creating a class derived from CButton, however there no TransparentBlt API in EVC3.0. Anyway to do TransparentBlt?:( Thanks Lane