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. Dialog Control Transparent Property

Dialog Control Transparent Property

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 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.
  • S Offline
    S Offline
    softwaremonkey
    wrote on last edited by
    #1

    Hi, I have changed the background colour of one of my dialogs by handling the WM_CTLCOLOR message. This works OK but the child controls are still painted using the original dialog background colour. I have set the transparent property of the child controls but this makes no difference. Is there something else I need to do? :doh: Thanks Tony

    A 1 Reply Last reply
    0
    • S softwaremonkey

      Hi, I have changed the background colour of one of my dialogs by handling the WM_CTLCOLOR message. This works OK but the child controls are still painted using the original dialog background colour. I have set the transparent property of the child controls but this makes no difference. Is there something else I need to do? :doh: Thanks Tony

      A Offline
      A Offline
      Andrew Brock
      wrote on last edited by
      #2

      What are your child controls? Static text? Typically you would need to override the WM_ERASEBKGND (OnEraseBkgnd in MFC) in the child controls to stop it painting the background or to copy the parent background (depending on what you are doing). Check out some of the transparent controls[^] in the articles section.

      S 1 Reply Last reply
      0
      • A Andrew Brock

        What are your child controls? Static text? Typically you would need to override the WM_ERASEBKGND (OnEraseBkgnd in MFC) in the child controls to stop it painting the background or to copy the parent background (depending on what you are doing). Check out some of the transparent controls[^] in the articles section.

        S Offline
        S Offline
        softwaremonkey
        wrote on last edited by
        #3

        My dialog contains a mixture of control types, including CStatic, CEdit etc. I have discovered that if I call pDC->SetBkMode(TRANSPARENT) in my dialog's OnCtlColor() handler then all of the child static controls have a transparent background - GREAT! - but unfortunately, so do my edit controls. So close but yet so far :sigh: I was hoping that I would be able to create a generic dialog class which would allow me to set the background colour without me having to fiddle with the child controls on an individual basis. :sigh:

        A 1 Reply Last reply
        0
        • S softwaremonkey

          My dialog contains a mixture of control types, including CStatic, CEdit etc. I have discovered that if I call pDC->SetBkMode(TRANSPARENT) in my dialog's OnCtlColor() handler then all of the child static controls have a transparent background - GREAT! - but unfortunately, so do my edit controls. So close but yet so far :sigh: I was hoping that I would be able to create a generic dialog class which would allow me to set the background colour without me having to fiddle with the child controls on an individual basis. :sigh:

          A Offline
          A Offline
          Andrew Brock
          wrote on last edited by
          #4

          Ok, great start. Check out the MSDN page[^] for OnCtlColor(). Notice the nCtlColor parameter? Only do pDC->SetBkMode(TRANSPARENT) if it is equal to CTLCOLOR_STATIC and you should be set. EDIT: If you only want to set specific controls as transperent, rather than all controls of a type, check if pWnd is the instance you want to set instead.

          S 1 Reply Last reply
          0
          • A Andrew Brock

            Ok, great start. Check out the MSDN page[^] for OnCtlColor(). Notice the nCtlColor parameter? Only do pDC->SetBkMode(TRANSPARENT) if it is equal to CTLCOLOR_STATIC and you should be set. EDIT: If you only want to set specific controls as transperent, rather than all controls of a type, check if pWnd is the instance you want to set instead.

            S Offline
            S Offline
            softwaremonkey
            wrote on last edited by
            #5

            Thanks Andrew - works a treat :thumbsup: :thumbsup:

            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