views:

78

answers:

4

I have a form in an application developed using C#. In that form I have created a graphic shape (a circle). At run-time I want my form also to be of that shape only. That is, I want to display only that graphic and not the form back ground or title bar or anything. I want to display only that graphic. But the thing is I'm not able to shape my form. I have that graphic control as a User-Control which I have added to my form.

+2  A: 

I suspect you're trying to make a splash-screen like effect. This isn't terribly hard to do. Here's a good tutorial to get you started.

The trick essentially is to set the transparency key of the form to the color you wish to be transparent (in this case, everything except your circle. Additionally, you need to set the form to be borderless.


As an aside, you might edit your question to add some information about why you want to do this - I am curious what your goal is, in terms of user-experience.

Charlie Salts
just want to show some graphic to user in my form whenever an event occurs. Graphic comes as a separate form and i want that form to be invisible and only graphic come as a picture.
jankhana
+1  A: 

You could also check MSDN for the Region property. You can use System.Drawing objects to draw whatever shape you want then set the forms Region property before its shown and it will take whatever shape you give it...heres a short example:

http://www.vcskicks.com/custom_shape_form_region.php

sokket
+1  A: 

If you want a circular form you can put the following code in the form load event handler:

System.Drawing.Drawing2D.GraphicsPath myPath = new  System.Drawing.Drawing2D.GraphicsPath();
//this line of code adds an ellipse to the graphics path that inscribes
//the rectangle defined by the form's width and height
myPath.AddEllipse(0,0,this.Width,this.Height);
//creates a new region from the GraphicsPath
Region myRegion = new Region(myPath);
this.Region = myRegion;

and then set the FormBorderStyle property of the form to None.

SubPortal
This i tried but my graphic is in circle like a speedometer and this comes as a ellipse which i don't want i even tried to give widht and height as my control plus some value but it does't escapes the title bar and it looks bad...any other suggestion????
jankhana
A circle *is* an ellipse...
Charlie Salts
Although an ellipse is most often not a circle.
Charlie Salts
A: 

Hey that tutorial is superb. That transparency concept worked. Thanks...

jankhana
Which tutorial?? If it worked, mark the appropriate answer as being the correct answer, please.
Charlie Salts