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. Windows Forms
  4. Hierarchy & Transparent Controls

Hierarchy & Transparent Controls

Scheduled Pinned Locked Moved Windows Forms
helpjavacomgame-devjson
5 Posts 3 Posters 2 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.
  • C Offline
    C Offline
    CompMan44
    wrote on last edited by
    #1

    I'm working on a game API which uses potentially transparent controls for basic layering effects (I don't want anything too fancy just yet). My first problem was enabling transparency, but that was easily solved using SetStyle(). Unfortunately, when I then tried placing a transparent layer over another layer, it shows the form's background color (here, black) through the transparency, instead of the layer beneath. I was finally able to get the proper effect by making the top-layer control a child of the bottom-layer control, but doing it that way makes some other effects nigh impossible. Is there a way to get transparent controls to display the other controls beneath them? Any help is appreciated.

    A little learning is a dangerous thing; Drink deep, or taste not, the Pierian Spring. —Alexander Pope

    R D 2 Replies Last reply
    0
    • C CompMan44

      I'm working on a game API which uses potentially transparent controls for basic layering effects (I don't want anything too fancy just yet). My first problem was enabling transparency, but that was easily solved using SetStyle(). Unfortunately, when I then tried placing a transparent layer over another layer, it shows the form's background color (here, black) through the transparency, instead of the layer beneath. I was finally able to get the proper effect by making the top-layer control a child of the bottom-layer control, but doing it that way makes some other effects nigh impossible. Is there a way to get transparent controls to display the other controls beneath them? Any help is appreciated.

      A little learning is a dangerous thing; Drink deep, or taste not, the Pierian Spring. —Alexander Pope

      R Offline
      R Offline
      Richard Blythe
      wrote on last edited by
      #2

      I would advise you to create you own class for layered effects. Its not as hard as it sounds! My method for creating your app would be to draw all my layers from my custom classes.

      1 Reply Last reply
      0
      • C CompMan44

        I'm working on a game API which uses potentially transparent controls for basic layering effects (I don't want anything too fancy just yet). My first problem was enabling transparency, but that was easily solved using SetStyle(). Unfortunately, when I then tried placing a transparent layer over another layer, it shows the form's background color (here, black) through the transparency, instead of the layer beneath. I was finally able to get the proper effect by making the top-layer control a child of the bottom-layer control, but doing it that way makes some other effects nigh impossible. Is there a way to get transparent controls to display the other controls beneath them? Any help is appreciated.

        A little learning is a dangerous thing; Drink deep, or taste not, the Pierian Spring. —Alexander Pope

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        CompMan44 wrote:

        Unfortunately, when I then tried placing a transparent layer over another layer, it shows the form's background color (here, black) through the transparency, instead of the layer beneath.

        This is exactly what it's supposed to do. The color Transparent is anything but. Transparent tells the control's background properties to match those of the parent container. It does NOT make the control Transparent. As you've found out, control-over-control transparency doesn't work the way the term "Transparent" would lead you to believe. The way around this is to not use controls to draw your graphics. Instead, you should be drawing your graphics to an off-screen buffer and "flip pages" between what's being drawn on and what the user sees, or use DirectX, where you'll have FAR more control over your graphics.

        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007

        C 1 Reply Last reply
        0
        • D Dave Kreskowiak

          CompMan44 wrote:

          Unfortunately, when I then tried placing a transparent layer over another layer, it shows the form's background color (here, black) through the transparency, instead of the layer beneath.

          This is exactly what it's supposed to do. The color Transparent is anything but. Transparent tells the control's background properties to match those of the parent container. It does NOT make the control Transparent. As you've found out, control-over-control transparency doesn't work the way the term "Transparent" would lead you to believe. The way around this is to not use controls to draw your graphics. Instead, you should be drawing your graphics to an off-screen buffer and "flip pages" between what's being drawn on and what the user sees, or use DirectX, where you'll have FAR more control over your graphics.

          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007

          C Offline
          C Offline
          CompMan44
          wrote on last edited by
          #4

          Dave Kreskowiak wrote:

          Transparent tells the control's background properties to match those of the parent container. It does NOT make the control Transparent.

          I was afraid of that. Actually, I'm using a custom OnPaint handler, so I guess FillRectangle() et al. is where that "feature" lies? Thanks for your suggestions. I'd rather not get into DirectX just yet, but if that's what it takes.... P.S. Are there ANY functions (preferably GDI) that handle transparent and semi-transparent colors properly?

          A little learning is a dangerous thing; Drink deep, or taste not, the Pierian Spring.      —Alexander Pope

          D 1 Reply Last reply
          0
          • C CompMan44

            Dave Kreskowiak wrote:

            Transparent tells the control's background properties to match those of the parent container. It does NOT make the control Transparent.

            I was afraid of that. Actually, I'm using a custom OnPaint handler, so I guess FillRectangle() et al. is where that "feature" lies? Thanks for your suggestions. I'd rather not get into DirectX just yet, but if that's what it takes.... P.S. Are there ANY functions (preferably GDI) that handle transparent and semi-transparent colors properly?

            A little learning is a dangerous thing; Drink deep, or taste not, the Pierian Spring.      —Alexander Pope

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #5

            Since Windows Forms is based on GDI+, no, there isn't.

            Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                 2006, 2007

            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