carl.manaster@gmail.com
12/20/2004 9:56:00 PM
Hi, Bob, and thanks -
> How are you painting your oddly shaped form, can you post
> some example that shows the problem you're having?
Here's an example, boiled down about as far as I can. I replaced my
complex region with a simple circle, but with the topleft at (-10,
-10); you can see when the form is displayed that it is clipped and
only the positive coordinates are displayed.
Peace,
--Carl
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace CircularWindow
{
public abstract class FlexibleForm : Form
{
private Container components = null;
public FlexibleForm()
{
this.FormBorderStyle = FormBorderStyle.None;
InitializeComponent();
this.Load += new EventHandler(MakeShape);
}
protected void MakeShape(object sender, EventArgs e) {MakeRegions();}
protected void MakeRegions()
{
Region = MakeFormRegion();
}
protected abstract Region MakeFormRegion();
private void DisposeComponents()
{
if (components != null) components.Dispose();
}
protected override void Dispose(bool disposing)
{
if(disposing)
{DisposeComponents();}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackColor = Color.Red;
this.ClientSize = new System.Drawing.Size(300, 300);
this.Name = "FlexibleForm";
this.Text = "FlexibleForm";
}
#endregion
}
public class CircularForm:FlexibleForm
{
public CircularForm()
{
}
protected override Region MakeFormRegion()
{
GraphicsPath path = new GraphicsPath();
// here you see that the region includes negative coordinates;
// these are clipped out when the form is drawn
path.AddArc(new Rectangle(-10, -10, 100, 100), 0, 360);
path.CloseFigure();
return new Region(path);
}
[STAThread]
static void Main()
{
Application.Run(new CircularForm());
}
}
}