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. Control transparency

Control transparency

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
13 Posts 4 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.
  • D damir_tk

    Hi everybody. I just can not set a transparency for the cation part of the group box control. The project is a standat Visual C++ windows application, no MFC, I use ATL for windows (CDialogImpl), but it should be the same as for any other project that does not include the MFC. So, I can intercept the message that paints the static controls, and make static controls transparent like this in OnCtlColorStatic: ::SetBkMode((HDC)wParam, TRANSPARENT); return (LRESULT) GetStockObject (HOLLOW_BRUSH); but how to do that for a group box control? The caption of it gets a weird gray color, and I just can not get rid off it. Thanks.

    W Offline
    W Offline
    Waldermort
    wrote on last edited by
    #2

    You have a handle to the DC, did you trying setting the text color on it?

    D 1 Reply Last reply
    0
    • W Waldermort

      You have a handle to the DC, did you trying setting the text color on it?

      D Offline
      D Offline
      damir_tk
      wrote on last edited by
      #3

      The handle is to the message that notifies that the static controls needs to be re-drawn, there is no such message for a group-box control. Anyways, messages in ATL are much more complex than those in MFC. I am currently playing with the atlcontrols.h that comes with the new ATL 8 and is supposed to wrap most of the control's functionality...if someone does not help me here in the meantime. :) Anyways, thanks for your reply. Sarajevo, Bosnia

      W 1 Reply Last reply
      0
      • D damir_tk

        The handle is to the message that notifies that the static controls needs to be re-drawn, there is no such message for a group-box control. Anyways, messages in ATL are much more complex than those in MFC. I am currently playing with the atlcontrols.h that comes with the new ATL 8 and is supposed to wrap most of the control's functionality...if someone does not help me here in the meantime. :) Anyways, thanks for your reply. Sarajevo, Bosnia

        W Offline
        W Offline
        Waldermort
        wrote on last edited by
        #4

        A groupbox control IS a static control, thats why the messages are the same.

        D 1 Reply Last reply
        0
        • W Waldermort

          A groupbox control IS a static control, thats why the messages are the same.

          D Offline
          D Offline
          damir_tk
          wrote on last edited by
          #5

          No, a group box control is a BUTTON control, believe it or not. :)

          M W 2 Replies Last reply
          0
          • D damir_tk

            Hi everybody. I just can not set a transparency for the cation part of the group box control. The project is a standat Visual C++ windows application, no MFC, I use ATL for windows (CDialogImpl), but it should be the same as for any other project that does not include the MFC. So, I can intercept the message that paints the static controls, and make static controls transparent like this in OnCtlColorStatic: ::SetBkMode((HDC)wParam, TRANSPARENT); return (LRESULT) GetStockObject (HOLLOW_BRUSH); but how to do that for a group box control? The caption of it gets a weird gray color, and I just can not get rid off it. Thanks.

            M Offline
            M Offline
            Michael Dunn
            wrote on last edited by
            #6

            A group box is actually a button, so you need to handle WM_CTLCOLORBTN.

            --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ

            D 1 Reply Last reply
            0
            • D damir_tk

              No, a group box control is a BUTTON control, believe it or not. :)

              M Offline
              M Offline
              Mark Salsbery
              wrote on last edited by
              #7

              damir_tk wrote:

              ...a group box control is a BUTTON control...

              Indeed! ATL draws its own controls? It should be much easier to make transparent then. Making the Windows group box (BUTTON) control text transparent, OTOH, good luck!

              1 Reply Last reply
              0
              • M Michael Dunn

                A group box is actually a button, so you need to handle WM_CTLCOLORBTN.

                --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ

                D Offline
                D Offline
                damir_tk
                wrote on last edited by
                #8

                Yup...I already know that, however the group box never receives the WM_PAINT message, even tho it is a button. One of those nice little things that makes us a true masochists programming in Visual C++. Thanks.

                M 1 Reply Last reply
                0
                • D damir_tk

                  Yup...I already know that, however the group box never receives the WM_PAINT message, even tho it is a button. One of those nice little things that makes us a true masochists programming in Visual C++. Thanks.

                  M Offline
                  M Offline
                  Mark Salsbery
                  wrote on last edited by
                  #9

                  damir_tk wrote:

                  ...however the group box never receives the WM_PAINT message...

                  Neat! When does it draw itself then?

                  D 1 Reply Last reply
                  0
                  • M Mark Salsbery

                    damir_tk wrote:

                    ...however the group box never receives the WM_PAINT message...

                    Neat! When does it draw itself then?

                    D Offline
                    D Offline
                    damir_tk
                    wrote on last edited by
                    #10

                    See this...he figured out the same strange behavior, and his code works for the MFC, will never work for the ATL: http://www.codeproject.com/miscctrl/tgroupbox.asp[^]

                    M 1 Reply Last reply
                    0
                    • D damir_tk

                      See this...he figured out the same strange behavior, and his code works for the MFC, will never work for the ATL: http://www.codeproject.com/miscctrl/tgroupbox.asp[^]

                      M Offline
                      M Offline
                      Mark Salsbery
                      wrote on last edited by
                      #11

                      Thanks for the link. I looked at the code. I saw no "subclassing" going on besides what MFC already does for you. It is an owner drawn control implemented by overriding WM_PAINT and drawing the entire control instead of using the Windows ownerdraw interface. My point in previous posts is that no matter what wrapper you are using, if the control is a Windows control then aside from making an owner-drawn control, there's no way to magically change the way the control draws itself. Unfortunately, Microsoft chose to not fully implement transparency (via WS_EX_TRANSPARENT) in all controls and multi part controls like the group box that require more than one background brush do not work well with the WM_CTLCOLOR messages. I have no idea how ATL wraps a window, but if there's no way to intercept every message to the window then it sounds like a pretty lame wrapper. Even the lowly MFC lets you do that :)

                      D 1 Reply Last reply
                      0
                      • M Mark Salsbery

                        Thanks for the link. I looked at the code. I saw no "subclassing" going on besides what MFC already does for you. It is an owner drawn control implemented by overriding WM_PAINT and drawing the entire control instead of using the Windows ownerdraw interface. My point in previous posts is that no matter what wrapper you are using, if the control is a Windows control then aside from making an owner-drawn control, there's no way to magically change the way the control draws itself. Unfortunately, Microsoft chose to not fully implement transparency (via WS_EX_TRANSPARENT) in all controls and multi part controls like the group box that require more than one background brush do not work well with the WM_CTLCOLOR messages. I have no idea how ATL wraps a window, but if there's no way to intercept every message to the window then it sounds like a pretty lame wrapper. Even the lowly MFC lets you do that :)

                        D Offline
                        D Offline
                        damir_tk
                        wrote on last edited by
                        #12

                        Yup...thanks for your post. Looks like I am heading for another sleepless night.

                        1 Reply Last reply
                        0
                        • D damir_tk

                          No, a group box control is a BUTTON control, believe it or not. :)

                          W Offline
                          W Offline
                          Waldermort
                          wrote on last edited by
                          #13

                          Oh, sorry for that, I stand corrected.

                          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