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#
  4. Control in front of another one at all times

Control in front of another one at all times

Scheduled Pinned Locked Moved C#
algorithmsquestion
11 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.
  • F Offline
    F Offline
    fdsfsa76f7sa6
    wrote on last edited by
    #1

    Is there any way to keep control in front of another one at all times? I've been searching for quite a while and I've found nothing that really works. I've also tried with BringToFront method whenever the control beneath it gets focused and it doesn't really work as I want it to. Thanks in advance!

    realJSOPR L 2 Replies Last reply
    0
    • F fdsfsa76f7sa6

      Is there any way to keep control in front of another one at all times? I've been searching for quite a while and I've found nothing that really works. I've also tried with BringToFront method whenever the control beneath it gets focused and it doesn't really work as I want it to. Thanks in advance!

      realJSOPR Offline
      realJSOPR Offline
      realJSOP
      wrote on last edited by
      #2

      Change it's z-order.

      .45 ACP - because shooting twice is just silly
      -----
      "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
      -----
      "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

      F 1 Reply Last reply
      0
      • realJSOPR realJSOP

        Change it's z-order.

        .45 ACP - because shooting twice is just silly
        -----
        "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
        -----
        "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

        F Offline
        F Offline
        fdsfsa76f7sa6
        wrote on last edited by
        #3

        Already tried, doesn't work, because as soon as user actives the control below, parts of it come in front. I changed the z-order by writing

        this.Controls.SetChildIndex(myControl, 0);

        Do you know any other way?

        realJSOPR 1 Reply Last reply
        0
        • F fdsfsa76f7sa6

          Is there any way to keep control in front of another one at all times? I've been searching for quite a while and I've found nothing that really works. I've also tried with BringToFront method whenever the control beneath it gets focused and it doesn't really work as I want it to. Thanks in advance!

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          I doubt there will be a solution; anyway you probably didn't provide enough details here. if the bottom control supports interaction, e.g. it is a TextBox and is enabled, then it not coming to the front would normally considered bad. So what is it that you want enabled and not topmost when activated? :)

          Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

          Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

          F 1 Reply Last reply
          0
          • L Luc Pattyn

            I doubt there will be a solution; anyway you probably didn't provide enough details here. if the bottom control supports interaction, e.g. it is a TextBox and is enabled, then it not coming to the front would normally considered bad. So what is it that you want enabled and not topmost when activated? :)

            Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

            Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

            F Offline
            F Offline
            fdsfsa76f7sa6
            wrote on last edited by
            #5

            It's a Panel on top of ScrollableControl. I have painted a custom "toolbar" on my form (it's just a drawing, not a control), and I want to add shadow to it. To achieve a look as if drawings in ScrollableControl are going under the toolbar-drawing, I need to separate the shadow into a control and put over it. The shadow-panel is 2 pixels high, has transparent background and has 2 black lines with different alpha value painted on it. Adding the shadow to the ScrollableControl instead of to the form doesn't work, because vertical scrollbar gets over the shadow (gets focused) and I'd also have to keep the shadow steady on scrolling (every control you put inside ScrollableControl will get scrolled). It's the least important thing, but I always like to add some eye-candy to my applications.

            L 1 Reply Last reply
            0
            • F fdsfsa76f7sa6

              It's a Panel on top of ScrollableControl. I have painted a custom "toolbar" on my form (it's just a drawing, not a control), and I want to add shadow to it. To achieve a look as if drawings in ScrollableControl are going under the toolbar-drawing, I need to separate the shadow into a control and put over it. The shadow-panel is 2 pixels high, has transparent background and has 2 black lines with different alpha value painted on it. Adding the shadow to the ScrollableControl instead of to the form doesn't work, because vertical scrollbar gets over the shadow (gets focused) and I'd also have to keep the shadow steady on scrolling (every control you put inside ScrollableControl will get scrolled). It's the least important thing, but I always like to add some eye-candy to my applications.

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              I'm not an eye candy specialist, however if memory serves, the way to go is by having your regular Control in the back, and a special transparent panel on top of that. You paint whatever it takes on the panel, and teach it to sit in front visually, while being invisible to all mouse operations, so it clicks through. I did something similar once, long ago, however I don't remember every detail. :)

              Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

              Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

              F 1 Reply Last reply
              0
              • F fdsfsa76f7sa6

                Already tried, doesn't work, because as soon as user actives the control below, parts of it come in front. I changed the z-order by writing

                this.Controls.SetChildIndex(myControl, 0);

                Do you know any other way?

                realJSOPR Offline
                realJSOPR Offline
                realJSOP
                wrote on last edited by
                #7

                But does the control that's on top become obstructed by the control beneath it? I've given it some though and I can't come up with a reason to do what you're doing. If you want to hide some controls based on conditions in the form, just hide 'em or disable 'em.

                .45 ACP - because shooting twice is just silly
                -----
                "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
                -----
                "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

                1 Reply Last reply
                0
                • L Luc Pattyn

                  I'm not an eye candy specialist, however if memory serves, the way to go is by having your regular Control in the back, and a special transparent panel on top of that. You paint whatever it takes on the panel, and teach it to sit in front visually, while being invisible to all mouse operations, so it clicks through. I did something similar once, long ago, however I don't remember every detail. :)

                  Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                  Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

                  F Offline
                  F Offline
                  fdsfsa76f7sa6
                  wrote on last edited by
                  #8

                  I know I'm asking a lot, but could you please try to write an example code how to keep a control in front visually and how to make it click-through-able? Thanks in advance!

                  L 1 Reply Last reply
                  0
                  • F fdsfsa76f7sa6

                    I know I'm asking a lot, but could you please try to write an example code how to keep a control in front visually and how to make it click-through-able? Thanks in advance!

                    L Offline
                    L Offline
                    Luc Pattyn
                    wrote on last edited by
                    #9

                    Sorry no, it was really long ago, and I don't want to go there again. :)

                    Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                    Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

                    F 1 Reply Last reply
                    0
                    • L Luc Pattyn

                      Sorry no, it was really long ago, and I don't want to go there again. :)

                      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                      Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

                      F Offline
                      F Offline
                      fdsfsa76f7sa6
                      wrote on last edited by
                      #10

                      I hope you can give me at least a hint in the right direction... Was it win32-like code or just overriding some functions? I'm more interested in how to keep a panel visually in front at all times. Thanks for the help.

                      L 1 Reply Last reply
                      0
                      • F fdsfsa76f7sa6

                        I hope you can give me at least a hint in the right direction... Was it win32-like code or just overriding some functions? I'm more interested in how to keep a panel visually in front at all times. Thanks for the help.

                        L Offline
                        L Offline
                        Luc Pattyn
                        wrote on last edited by
                        #11

                        1. make sure the background control (ListBox, whatever) and the foreground control (Panel) both have the Form as their parent. (If you were to use Visual Dersigner, and simply add the background control first, then a smaller foreground Control on top of it, it would be a child of the background, not of the form). One way of doing that is: position it outside the background color, select it, goto properties, and type a new location value. 2. at run-time, never move the controls, never change their Z-order. Let them as they are. 3. in as much as the foreground control must be transparent (visually) and must ignore the mouse (click-through), do whatever that takes (Enabled=false; for starters). :)

                        Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                        Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

                        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