Shape and line controls, only a little more interactive?
Colleagues,
Are there controls that have the visual properties of a shape and line controls, and also have better mouse support, so that they can be made more interactive?
I’m writing an application that has a process diagram. I’d like to add things like ToolTips and to make some elements on the diagram clickable.
I know that I can put a label on a shape and it would provide the mouse support that I need. It would work for square-ish shapes, but it doesn’t work well for circles.
- Nick
Re: Shape and line controls, only a little more interactive?
Unless someone has made these already your best bet might be to make your own, either as usercontrols or as some sort of graphics class.
Re: Shape and line controls, only a little more interactive?
Quote:
Originally Posted by kender
Colleagues,
I know that I can put a label on a shape and it would provide the mouse support that I need. It would work for square-ish shapes, but it doesn’t work well for circles.
- Nick
Not true! If you code it correctly you can put a Label inside an Oval Shape and it looks a hell of a lot better than a circle. You can also write code that will autosize the shape as the label text increases and decreases.
That said, there's a BalloonTip file using an API right here on the forum. Do a search for it in the Code Bank. :)
Re: Shape and line controls, only a little more interactive?
I think one of the problems are the mouse events. Click an image showing a circle and it's the images rectangle that responds. I think the OP wants a shape that raises an event only if the image has been clicked (not the rectangle)
Re: Shape and line controls, only a little more interactive?
Quote:
Originally Posted by Milk
I think one of the problems are the mouse events. Click an image showing a circle and it's the images rectangle that responds. I think the OP wants a shape that raises an event only if the image has been clicked (not the rectangle)
Exactly. Mouse events are the biggets problem. For a cicrle, the corners of the control rectangle shouldn't respond to mouse events.
1 Attachment(s)
Re: Shape and line controls, only a little more interactive?
Quote:
Originally Posted by Milk
I think one of the problems are the mouse events. Click an image showing a circle and it's the images rectangle that responds. I think the OP wants a shape that raises an event only if the image has been clicked (not the rectangle)
The attached Gif image consists of 1 Label, 1 Shape and a LineControl array. The whole thing expands and contracts with the text count in the Label.
Re: Shape and line controls, only a little more interactive?
Quote:
Originally Posted by Milk
I think one of the problems are the mouse events. Click an image showing a circle and it's the images rectangle that responds. I think the OP wants a shape that raises an event only if the image has been clicked (not the rectangle)
My apologies for misunderstanding the question. After sleeping on it (need more), I realize that it's not a tool tip that you want. Milk is correct when he suggested building your own shape control with events & properties that you want. :rolleyes:
Re: Shape and line controls, only a little more interactive?
Just use a picturebox control with no border and flat apearance. Then use the MouseDown event to get the x, y location of the click and GetPixel API to get the pixel color associated with that point. If its got color then it was clicked on the image. :D
1 Attachment(s)
Re: Shape and line controls, only a little more interactive?
It's actually pretty easy to create a user control with a custom clickable area. Just set the BackStyle of the UserControl to 0 (transparant) and assign a MaskPicture for the area that should react to the mouse events. The transparent part (which will not react to any mouse events) will then be the any part of the MaskPicture that have the same color as the MaskColor property of the UserControl. Attached is an example.