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. Transparent control

Transparent control

Scheduled Pinned Locked Moved C / C++ / MFC
graphicstutorialquestion
5 Posts 3 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.
  • M Offline
    M Offline
    MemLeak
    wrote on last edited by
    #1

    Hi, I have a dialog that have a bitmap as background. When I put control on the dialog, I can see the surrounding white rectangle around the controls. Is there a way to see my background around the controls and not the white rectangle? for example, suppose that I have a CStatic with text in it, is there a way to to see the bitmap behind the text? thanks Everything's beautiful if you look at it long enough...

    R 1 Reply Last reply
    0
    • M MemLeak

      Hi, I have a dialog that have a bitmap as background. When I put control on the dialog, I can see the surrounding white rectangle around the controls. Is there a way to see my background around the controls and not the white rectangle? for example, suppose that I have a CStatic with text in it, is there a way to to see the bitmap behind the text? thanks Everything's beautiful if you look at it long enough...

      R Offline
      R Offline
      Rage
      wrote on last edited by
      #2

      Does enabling the Transparent property (when right-clicking on the control in the ressource editor) change something ? ~RaGE();

      M 1 Reply Last reply
      0
      • R Rage

        Does enabling the Transparent property (when right-clicking on the control in the ressource editor) change something ? ~RaGE();

        M Offline
        M Offline
        MemLeak
        wrote on last edited by
        #3

        No, enabling the transparent property don't change anything. I have been able to make it work throught OnPaint() redefinition in a CStatic control, but I cannot use to make it work for other controls such as CButton (radio button) for CStatic, in the OnPaint of the control you can use: dc.setBkMode(TRANSPARENT) dc.DrawText(...) Everything's beautiful if you look at it long enough...

        B 1 Reply Last reply
        0
        • M MemLeak

          No, enabling the transparent property don't change anything. I have been able to make it work throught OnPaint() redefinition in a CStatic control, but I cannot use to make it work for other controls such as CButton (radio button) for CStatic, in the OnPaint of the control you can use: dc.setBkMode(TRANSPARENT) dc.DrawText(...) Everything's beautiful if you look at it long enough...

          B Offline
          B Offline
          basementman
          wrote on last edited by
          #4

          Try adding a handler for OnEraseBkgnd and either doing nothing or erasing the background with a hollow brush. ex: BOOL MyDialog::OnEraseBkgnd( CDC* pDC ) { return TRUE; }

          M 1 Reply Last reply
          0
          • B basementman

            Try adding a handler for OnEraseBkgnd and either doing nothing or erasing the background with a hollow brush. ex: BOOL MyDialog::OnEraseBkgnd( CDC* pDC ) { return TRUE; }

            M Offline
            M Offline
            MemLeak
            wrote on last edited by
            #5

            Well, I doesn't seem to work, I also tried to use: HBRUSH RightDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = ShapedDlg::OnCtlColor(pDC, pWnd, nCtlColor); if ( pWnd->GetDlgCtrlID() == IDC_RADIO1) { // m_bkbrush is a CBrush member variable m_bkbrush.CreateStockObject(HOLLOW_BRUSH); pDC->SetBkMode ( TRANSPARENT ); return m_bkbrush; } return hbr; } If I use BLACK_BRUSH, I will see a black background if I use GREY_BRUSH I will see grey background, but HOLLOW_BRUSH give me a strange blue background. Everything's beautiful if you look at it long enough...

            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