Control in front of another one at all times
-
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!
-
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!
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 -
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, 2001Already 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?
-
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!
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.
-
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.
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.
-
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.
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.
-
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?
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 -
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.
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!
-
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!
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.
-
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.
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.
-
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.
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.