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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Placing transparent bitmaps into dialogs

Placing transparent bitmaps into dialogs

Scheduled Pinned Locked Moved C / C++ / MFC
comgraphicshelpquestionlearning
2 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.
  • R Offline
    R Offline
    Rafael Fernandez Lopez
    wrote on last edited by
    #1

    Hi, I want to put a semi-transparent bitmap into my dialog, and I've the following code: BLENDFUNCTION bf; bf.AlphaFormat = 0; bf.BlendFlags = 0; bf.BlendOp = AC_SRC_OVER; bf.SourceConstantAlpha = 0x7f; CRect rect; GetDlgItem(IDC_PRUEBA_TRANS)->GetWindowRect(&rect); CClientDC dc(this); CDC dcMem; dcMem.CreateCompatibleDC(&dc); AlphaBlend(GetDlgItem(IDC_PRUEBA_TRANS)->GetDC()->GetSafeHdc(), 0, 0, rect.Width(), rect.Height(), dc, 0, 0, rect.Width(), rect.Height(), bf); This code purpose was to test if AlphaBlend is working all-right with my dialog, and it seem that it does. Now my problem is: I've bitmaps as "BITMAPS" in my resource file. IDC_PRUEBA_TRANS is a CStatic Ctrl with Bitmap enabled and a Bitmap loaded through designer (not code). If I do such: AlphaBlend(dc, 0, 0, rect.Width(), rect.Height(), dcMem, 0, 0, rect.Width(), rect.Height(), bf); The transparent bitmap will be drawn on the opaque one, so the transparency will not be visible (for that reason, I tried to put a form shot into IDC_PRUEBA_TRANS, to test it). So I'd like to know how can I get a CDC from a CBitmap or whatever way of do this thing... Thank you, Rafael Fernández López.


    Written by: Rafael Fernández López.

    Visit: http://www.maestroprogramador.com

    J 1 Reply Last reply
    0
    • R Rafael Fernandez Lopez

      Hi, I want to put a semi-transparent bitmap into my dialog, and I've the following code: BLENDFUNCTION bf; bf.AlphaFormat = 0; bf.BlendFlags = 0; bf.BlendOp = AC_SRC_OVER; bf.SourceConstantAlpha = 0x7f; CRect rect; GetDlgItem(IDC_PRUEBA_TRANS)->GetWindowRect(&rect); CClientDC dc(this); CDC dcMem; dcMem.CreateCompatibleDC(&dc); AlphaBlend(GetDlgItem(IDC_PRUEBA_TRANS)->GetDC()->GetSafeHdc(), 0, 0, rect.Width(), rect.Height(), dc, 0, 0, rect.Width(), rect.Height(), bf); This code purpose was to test if AlphaBlend is working all-right with my dialog, and it seem that it does. Now my problem is: I've bitmaps as "BITMAPS" in my resource file. IDC_PRUEBA_TRANS is a CStatic Ctrl with Bitmap enabled and a Bitmap loaded through designer (not code). If I do such: AlphaBlend(dc, 0, 0, rect.Width(), rect.Height(), dcMem, 0, 0, rect.Width(), rect.Height(), bf); The transparent bitmap will be drawn on the opaque one, so the transparency will not be visible (for that reason, I tried to put a form shot into IDC_PRUEBA_TRANS, to test it). So I'd like to know how can I get a CDC from a CBitmap or whatever way of do this thing... Thank you, Rafael Fernández López.


      Written by: Rafael Fernández López.

      Visit: http://www.maestroprogramador.com

      J Offline
      J Offline
      John R Shaw
      wrote on last edited by
      #2

      Just off the top of my head, but do not set the static control to load the bitmap. If you can draw the bitmap your self, then you already know that it will fit (or can be made to fit) within the static controls rectangular client area. Set the static control to just provide the rectangular area where the drawing will occur, basicaly a place holder. INTP Every thing is relative...

      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