Non-rectangular forms

G

Guest

Hi

I'm working on a project with a non-rectangular form. I found that if in the form constructor I define a region, say

GraphicsPath p = new GraphicsPath()
p.AddEllipse(20, 20, 200, 200)
this.Region = new Region(p)

I get a shaped form with no non-client areas which is exactly what I want.
My problem is I don't understand WHY this works. Shouldn't the OnPaint event override my code
I'd be grateful for any explanation of what's going on here

Regard

Tony Reynolds
 
B

Bob Powell [MVP]

The region supplied to the form creates a clipping area that you cannot
paint outside of. If you could it would be possible to draw a line
from -1000, 100 to 1000,100 and it would go right across the desktop. This
clearly isn't the case.

Normal windows have a rectangular clipping region, in the case of a shaped
form the rectangle is replaced by whatever you assign.

--
Bob Powell [MVP]
C#, System.Drawing

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

Tony Reynolds said:
Hi -

I'm working on a project with a non-rectangular form. I found that if in
the form constructor I define a region, say,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top