No announcement yet.

Making a childwindow transparent or "combining WS_EX_LAYERED with WS_CHILD"

  • Filter
  • Time
  • Show
Clear All
new posts

  • Making a childwindow transparent or "combining WS_EX_LAYERED with WS_CHILD"


    Little problem: I've got a Childwindow, which is on top of other childwindows. I have to make the topmost childwindow a little bit transparent.

    But MSDN says (and is incredibly right)
    Note that WS_EX_LAYERED cannot be used for child windows.
    Is there a workaround for layered childwindows?

    Best regards,
    Marc Giesmann

  • #2
    Maybe you can gin up a demo which would show the effect you wish to achieve; from that, someone may have an idea for you. You can show the effect with a "non-child" window and ask if anyone knows how to do it with a "child" window.

    "A little bit transparent" is just a tad to ephemeral for me to visualize.

    But just off the top of my head, why not just handle WM_PAINT and/or WM_ERASEBKGND yourself? (Warning: drawing is not my strong suit).

    Or, maybe there is something in either GDI or GDIPlus which can help you create the desired effect?

    Or, don't make the window a child window; make it no parent, with style WS_EX_TOOLWINDOW to eliminate the task bar entry; and then do "something" with that when painted.

    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]


    • #3
      Child windows can not use the layered window feature of XP or Vista, as far as I know.

      A lot depends upon what is on the child window.

      If the child window simply needs to let the dialog area show through, while not any of the controls on it., thats relatively easy. You create a region which matchs only the area you want to be visible and then set the window to use that region. A region allows you to have a non-rectangular window of any shape desired.

      If you need the backgeound windows to bleed through partially (alphablending the child window to its background windows) I don't think you will be able to do it.

      Now you could make the child window a top level window instead (no longer a child) and also topmost. This will keep it above the others and you can using layering.
      Chris Boss
      Computer Workshop
      Developer of "EZGUI"


      • #4
        First, thanks to all. After some more research I just made my RECT Window a WS_POPUP window, and clipped with

        LOCAL tWindowRect AS RECT
        GetWindowRect(hWorkspace, tWindowRect)

        the mousecursor in the window. Thats quite the same effect than a childwindow has. Okay, it steals for the time of sizing/moving the focus from my mainwindow (even If I call "DIALOG SHOW STATE hWndSELECTRECT, %SW_SHOWNA" before showing it), but thats okay.

        To have an example for what I was trying to immitate, just use WinXP on standard configuration, and highlight some more icons by using the rectangle-feature in the windows explorer. Click on an empty area and drag the mouse over some icons.

        There should be a blue, but transparent rectangle.

        Thanks again, and have a nice weekend
        Marc Giesmann


        • #5
          Sounds something more up the line of something Patrice may know about??? (but who knows?)
          Engineer's Motto: If it aint broke take it apart and fix it

          "If at 1st you don't succeed... call it version 1.0"

          "Half of Programming is coding"....."The other 90% is DEBUGGING"

          "Document my code????" .... "WHYYY??? do you think they call it CODE? "


          • #6
            just handled everything as I wished it to be

            The only thing I've had to add was


            and now my choosing-rect isn't stealing my focus anymore, works like a charm and lookspretty nice- even on "normal" machine (P4 HT). Some flickers to remove yet, but that won't bother me too much.

            Thanks again, best regards,
            Marc Giesmann

            If anyone still has a workaround for the childwindow with transluency issue, please do it. I still think, that a solution like that would be much more comfortable for me.


            • #7
              You must go to plain SDK mode and perform the drawing yourself, using full 32-bit drawing mode.

              And the secret is to work in composited mode:

              Last edited by Patrice Terrier; 8 Jan 2011, 01:14 PM.
              Patrice Terrier
              Addons: GDImage.DLL 32/64-bit (Graphic library), WinLIFT.DLL 32/64-bit (Skin Engine).