Tooltip on disabled controls?
-
Hi! Could any one suggest me how I can display tooltips for a disabled controls! It was fairly easy to implement the same in MFC but em not able to find a solution in C# :( Thanks in advance!
- Nilesh "Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
-
Hi! Could any one suggest me how I can display tooltips for a disabled controls! It was fairly easy to implement the same in MFC but em not able to find a solution in C# :( Thanks in advance!
- Nilesh "Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
-
place another control behind the disabled control so that only when your control is disabled then mouse events go to that control, in that control's mouse move event call tooltip.settooltip for the control that is behind.
Regards Shajeel
-
Thanks! But my application is having too many controls, and having duplicate control underneath each really blots it up :( - Nilesh
Hi You can add hidden control (HTML or asp:hiddenfield) as this will not disturb your UI. :)
Harini
-
Thanks! But my application is having too many controls, and having duplicate control underneath each really blots it up :( - Nilesh
-
i think a better solution will to created user controls for all controls you use, but it will be time consuming and you will have to replace all your control in your application with custom controls.
Regards Shajeel
-
Thanks! But my application is having too many controls, and having duplicate control underneath each really blots it up :( - Nilesh
Yes, it should be (considered) forbidden to frivolously use resources. Documentation tells us that tootips are never displayed for disabled controls. That means the behavior is not supported by the tooltip class. You would have to write your own tooltip-like class to detect mouse-over and so forth if you wanted to override this behavior, but that would be a steep price to pay to provide a tooltip for something that isn't functional at the moment in the first place.
-
Yes, it should be (considered) forbidden to frivolously use resources. Documentation tells us that tootips are never displayed for disabled controls. That means the behavior is not supported by the tooltip class. You would have to write your own tooltip-like class to detect mouse-over and so forth if you wanted to override this behavior, but that would be a steep price to pay to provide a tooltip for something that isn't functional at the moment in the first place.
Was wondering if there was any workaround, similar problem is seen with MFC controls as well but there you have the pretranslatemessage which allows you to handle it by sending explict messages to tooltip controler. Is it possible to implement something similar here too:)
- Nilesh "Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
-
Was wondering if there was any workaround, similar problem is seen with MFC controls as well but there you have the pretranslatemessage which allows you to handle it by sending explict messages to tooltip controler. Is it possible to implement something similar here too:)
- Nilesh "Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
I really can't tell you that, but it's a good question, particularly as the disabled state itself could be an obstruction. I mean of course, that whenever someone discovers such a workaround, there's a good chance they walked down a few difficult dead ends (as successfully as possible) to find it -- so it's a good idea to ask in case someone might have the pattern handy. If so, it might be a long shot that such a person might see your post. Still, I think I'd lean away from this. Your post in fact first gave me the idea I might try a workaround to provide an additional capacity in a control I'm working on, but then I thought no, it's not often (if ever possibly) very logical to provide tooltips to disabled controls... so (for me at least, as far as I can see), I decided to accept the default functionality, particularly considering how much effort and resource overhead might be wasted to deliver the behavior you are asking for. That said, if you want pointed in the initial directions that strike me, what you might try that might not increase resource reliance too disproportionately, is detecting the parent of your control and setting the region of your control on the parent to take a mouse hit test, sampling the mouse state to raise your own hint possibly from the parent. That even may be too wild an idea or technically challenging a project.
-
I really can't tell you that, but it's a good question, particularly as the disabled state itself could be an obstruction. I mean of course, that whenever someone discovers such a workaround, there's a good chance they walked down a few difficult dead ends (as successfully as possible) to find it -- so it's a good idea to ask in case someone might have the pattern handy. If so, it might be a long shot that such a person might see your post. Still, I think I'd lean away from this. Your post in fact first gave me the idea I might try a workaround to provide an additional capacity in a control I'm working on, but then I thought no, it's not often (if ever possibly) very logical to provide tooltips to disabled controls... so (for me at least, as far as I can see), I decided to accept the default functionality, particularly considering how much effort and resource overhead might be wasted to deliver the behavior you are asking for. That said, if you want pointed in the initial directions that strike me, what you might try that might not increase resource reliance too disproportionately, is detecting the parent of your control and setting the region of your control on the parent to take a mouse hit test, sampling the mouse state to raise your own hint possibly from the parent. That even may be too wild an idea or technically challenging a project.
-
Thanks for the pointer, I too was thinking on the same line. To capture region of disabled object and set required tooltip for parent, let me give a shot at it.:) Thanks again! Nilesh
Well, good luck on that. Just one other thing. If your control is composite/aggregate of course, you should be able to pull this off without too much difficulty. Otherwise, it certainly would be a boon to be able to have an inside look at the ToolTip class. Some people say some of that kind of source can be found. If you can dig it up, the behavior you want may be no more difficult than overriding a method, possibly only to eliminate the logic fork that refrains from tooltip display when controls are disabled. Personally, I think Microsoft would benefit the development community tremendously by exposing selected source (like this) to us. Instead of our present far-reaching discussion without much tangible to present to each other, dozens of people could recommend just how to override whatever method. That's how it was in Delphi and C++Builder a few years back, before Borland management made the mistake of letting .Net blow them out of the water.