[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Jaydeep

12/15/2004 11:41:00 AM

Hello All

Here I am tring to cut my windows form using following code in OnPaint
event. Problem which I am facing is, when i change Form size by giving new
height and width. It is not repainting the form neatly. it shows thick black
border when you give new height and width. This code is written in a DLL
prject and a Test windows application is provided to test the functionality.
I am building windows application using C#


protected override void OnPaint(System.Windows.Forms.PaintEventArgs e )
{
base.OnPaint(e);
Graphics objDC=e.Graphics;
objPen1=new Pen(Color.Black ,2);
objPen2=new Pen(Color.Black ,5);
System.Drawing.Drawing2D.GraphicsPath objShape = new
System.Drawing.Drawing2D.GraphicsPath();
//Here OFFSET = 5
//here this.Width and this.Height represents new height and width pass as a
parameter.
Point[] p = {new Point(OFFSET,0), //1

new Point(this.Width-OFFSET,0), //2

new Point(this.Width,OFFSET), //3

new Point(this.Width,this.Height-OFFSET), //4

new Point(this.Width-OFFSET,this.Height), //5

new Point(OFFSET,this.Height), //6

new Point(0,this.Height-OFFSET), //7

new Point(0,OFFSET), //8

};

// Here I could have used AddPolygon method but then I was not able to draw
borders, so used AddLines
objShape.AddLines (p); //this will create shape but to show borders,
following code is written


objDC.DrawLine(objPen1,new Point(OFFSET,0),new Point(this.Width-OFFSET,0));
objDC.DrawLine(objPen1,new Point(this.Width-OFFSET,0),new
Point(this.Width,OFFSET));
objDC.DrawLine(objPen2,new Point(this.Width,OFFSET),new
Point(this.Width,this.Height-OFFSET));
objDC.DrawLine(objPen2,new Point(this.Width,this.Height-OFFSET),new
Point(this.Width-OFFSET,this.Height));
objDC.DrawLine(objPen2,new Point(this.Width-OFFSET,this.Height), new
Point(OFFSET,this.Height));
objDC.DrawLine(objPen1,new Point(OFFSET,this.Height), new
Point(0,this.Height-OFFSET));
objDC.DrawLine(objPen1,new Point(0,this.Height-OFFSET),new Point(0,OFFSET));
objDC.DrawLine(objPen1,new Point(0,OFFSET),new Point(OFFSET,0));



this.Region = new System.Drawing.Region(objShape); // finally assign this
region to Form's region property

}

I hope the code is useful to understand the problem, if not let me know...,
Please help me out...

TIA

Jaydeep