Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Transparency - please help, nothing works...

Transparency - please help, nothing works...

Scheduled Pinned Locked Moved C / C++ / MFC
graphicshelpc++regexquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    PatrykDabrowski
    wrote on last edited by
    #1

    Hello! For couple of weeks I still have a problem with transparent buttons on toolbar. Toolbar background is 24bit image, buttons are also 24bit, VS2003, WinXP. What I do (background): 1) Load standard 24bit BMP to CBitmap object 2) Create pattern brush based on bitmap from 1) 3) Use FillRect() inside OnEraseBkgnd(). Background is ok, drawing works fine. Now the buttons: Solution A: 1) Load 24bit BMP to CBitmap 2) Create CImageList based on 1) using ILC_COLOR32|ILC_MASK 3) Create mask by Add() function with proper RGB() transparent color 4) Use SetImageList() in toolbar control object RESULT -> NO transparency (round buttons have plain color in the transparent color spots) Solution B: 1) Load 24bit PNG with transparency to CImage 2) Create CBitmap based on (HBITMAP) operator from 1) 3) Continue steps 2-4 from Solution 1 RESULT -> NO transparency Solution C: 1) Use CImage like in Solution B but use directly SetBitmap() from CToolbar RESULT -> again no transparency. Is there any simple way to get it working?? Basicly I want to have transparent bitmap on buttons. That means, I want to see bankground texture in the 'holes' in buttons (where the button's color == transparent color) Please, enlighten me:) I've read many articles and found one solution but it was quite complicated and used many derived classes... ("BitmapToolBarResrch_en" project) Solution can be Win2k/XP+ for MFC. Thank a lot!!

    C 1 Reply Last reply
    0
    • P PatrykDabrowski

      Hello! For couple of weeks I still have a problem with transparent buttons on toolbar. Toolbar background is 24bit image, buttons are also 24bit, VS2003, WinXP. What I do (background): 1) Load standard 24bit BMP to CBitmap object 2) Create pattern brush based on bitmap from 1) 3) Use FillRect() inside OnEraseBkgnd(). Background is ok, drawing works fine. Now the buttons: Solution A: 1) Load 24bit BMP to CBitmap 2) Create CImageList based on 1) using ILC_COLOR32|ILC_MASK 3) Create mask by Add() function with proper RGB() transparent color 4) Use SetImageList() in toolbar control object RESULT -> NO transparency (round buttons have plain color in the transparent color spots) Solution B: 1) Load 24bit PNG with transparency to CImage 2) Create CBitmap based on (HBITMAP) operator from 1) 3) Continue steps 2-4 from Solution 1 RESULT -> NO transparency Solution C: 1) Use CImage like in Solution B but use directly SetBitmap() from CToolbar RESULT -> again no transparency. Is there any simple way to get it working?? Basicly I want to have transparent bitmap on buttons. That means, I want to see bankground texture in the 'holes' in buttons (where the button's color == transparent color) Please, enlighten me:) I've read many articles and found one solution but it was quite complicated and used many derived classes... ("BitmapToolBarResrch_en" project) Solution can be Win2k/XP+ for MFC. Thank a lot!!

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      there's a classic KB article (#79212) that gives the steps for a transparent Blt. but, it looks like MS has lost it. but, Google knows where to find it.

      image processing toolkits | batch image processing | blogging

      P 1 Reply Last reply
      0
      • C Chris Losinger

        there's a classic KB article (#79212) that gives the steps for a transparent Blt. but, it looks like MS has lost it. but, Google knows where to find it.

        image processing toolkits | batch image processing | blogging

        P Offline
        P Offline
        PatrykDabrowski
        wrote on last edited by
        #3

        Thanks for reply:) I've read this article... It means, I have to override WM_PAINT message and blit buttons by myself? Is there any way to 'prepare' somehow my bitmaps that Windows could draw them with transparency by its own routines, like it does for non-transparent toolbar buttons??? Ok, let's assume using WM_PAINT message, now I dont need WM_ERASEBKGND handler and should draw background and buttons in a single OnPaint handler? Thanks again:)

        C 1 Reply Last reply
        0
        • P PatrykDabrowski

          Thanks for reply:) I've read this article... It means, I have to override WM_PAINT message and blit buttons by myself? Is there any way to 'prepare' somehow my bitmaps that Windows could draw them with transparency by its own routines, like it does for non-transparent toolbar buttons??? Ok, let's assume using WM_PAINT message, now I dont need WM_ERASEBKGND handler and should draw background and buttons in a single OnPaint handler? Thanks again:)

          C Offline
          C Offline
          Chris Losinger
          wrote on last edited by
          #4

          PatrykDabrowski wrote:

          It means, I have to override WM_PAINT message and blit buttons by myself?

          yep. but you'd have to do that for a button with any kind of image. you can use icons, which have built-in transparency, if you want to simplify things. but you still have to handle OnPaint.

          PatrykDabrowski wrote:

          Is there any way to 'prepare' somehow my bitmaps that Windows could draw them with transparency by its own routines, like it does for non-transparent toolbar buttons???

          not with any built-in classes. but, there are dozens of bitmap button classes out there (a few really good ones here on CP). ex. : i like this one.

          image processing toolkits | batch image processing | blogging

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups