Shaped Controls
Hi their i hope somone can shed some light on this coz im stumped, I wish to make a button that is shaped prefrabaly to the image i have for the button. The image is a cresent shape and so isnt very easy to draw, ive looked at using paths and regiosn but i dont know anyway of driving one from the image has anyone any surgesions on the direction to take.
Aulternativly their is the posibility of using some direct X but i dont know how easy it would be to use or if it can do what i would like.
Any help would be ace thx
[535 byte] By [
95CKILMA] at [2007-11-19 10:16:04]

# 1 Re: Shaped Controls
Look at MSDN in the article:
Shaped Windows Forms and Controls in Visual Studio .NET
(You can reach it by choosing TransparencyKey property of a Form in index, and then choosing Creating Nonrectangular Windows Forms link, and then there is a link.)
# 4 Re: Shaped Controls
Ive happened apon another problem whilst using the graphics region button in teh link abouve. When i move it on my form it is ok however when it is moved over a transparent region it leaves an image of itself behind, any surgestions why this might occur?
# 5 Re: Shaped Controls
transparent region? I dont understand. if an image persists on a--what would be blank--region, thats because that region is not being invalidated properly.
is this transparent region part of your form or something else?
# 6 Re: Shaped Controls
sorry i wasnt clear :) ill try to explain.
My main form is an oval shape, its created by a gif image with transparency colour around the outside of the oval. The transparency key and the backcolour are both black and so this produces a transparent area around my oval shape.
The button is a cresent shape that is placed on one edge of the oval. this is produced using the piece of script provided by the codeproject on that link abouve. now if i make is so that the button moves when clicked if it moves to the left (further twards the center of my oval) it is fine, however if i make it move to the right it gose out over the area that on teh background is transparent if then i continue to make the image move it leaves behind an image of itself.
# 7 Re: Shaped Controls
did you try my recomendation and use the SetStyle to double buffer?
if that doesnt help, then create a plain class that extends from the button you are using, and in its constructor, set the double buffer styles there as well. that should help out with the invalidation. you can also call Invalidate on the button up event to force a re-draw of the area.
# 8 Re: Shaped Controls
i tryed both your surgestions, although from what i gather as it isnt a continuously moving image double buffering isnt whats needed.
i tryed the invalidate also tryed to do it to the region around the button using rectangal.
from what i can see it would seem that it dosnt invalidate the transparent area, once hte image reaches any part of the non transparent form or i take the transparancy off it dosnt have a problem