Click here to Skip to main content
15,914,417 members
Home / Discussions / C#
   

C#

 
GeneralGDI+ nonrectangular forms problem Pin
sstoyan20-Dec-04 22:18
sstoyan20-Dec-04 22:18 
GeneralRe: GDI+ nonrectangular forms problem Pin
Heath Stewart20-Dec-04 22:45
protectorHeath Stewart20-Dec-04 22:45 
GeneralRe: GDI+ nonrectangular forms problem Pin
sstoyan21-Dec-04 3:33
sstoyan21-Dec-04 3:33 
GeneralRe: GDI+ nonrectangular forms problem Pin
Heath Stewart21-Dec-04 8:16
protectorHeath Stewart21-Dec-04 8:16 
GeneralRe: GDI+ nonrectangular forms problem Pin
sstoyan21-Dec-04 9:54
sstoyan21-Dec-04 9:54 
GeneralRe: GDI+ nonrectangular forms problem Pin
Heath Stewart21-Dec-04 12:33
protectorHeath Stewart21-Dec-04 12:33 
GeneralRe: GDI+ nonrectangular forms problem Pin
sstoyan21-Dec-04 21:38
sstoyan21-Dec-04 21:38 
GeneralRe: GDI+ nonrectangular forms problem Pin
Heath Stewart22-Dec-04 6:59
protectorHeath Stewart22-Dec-04 6:59 
You shouldn't be doing redundant calculations in your OnPaint override; you waste CPU cycles. If the GraphicsPath doesn't change, then don't keep recalculating it. OnPaint (or rather, the WM_PAINT window message) is called many, many times by the OS.

To post code, simply copy and paste the code in between <PRE></PRE> tags and escape any characters like < with &lt;, > with &gt;, and & with &amp;

You also don't need VS.NET. I added csc.exe's directory (the Framework version directory) to my PATH environment variable (as well as the SDK's Bin directory) and do almost everything you'd see from me on this site using a vanilla text editor called VIM[^] and the command-line compiler.

With a VIM script, I can post this easily to this site:
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
 
class Test : Form
{
  static void Main()
  {
    Application.Run(new Test());
  }
 
  GraphicsPath grabHandle;
  Brush pathBrush = new SolidBrush(Color.Aqua);
  Pen pathPen = new Pen(Color.Red);
 
  Test()
  {
    GraphicsPath p = new GraphicsPath();
    Point[] points = new Point[] {
      new Point(0,0),
      new Point(100,0),
      new Point(150,50),
      new Point(250,50),
      new Point(250,350),
      new Point(0,350)};
    p.AddPolygon(points);
    this.Region = new Region(p);
 
    grabHandle = new GraphicsPath();
    points = new Point[] {
      new Point(0,0),
      new Point(100,0),
      new Point(150,50),
      new Point(0,50)};
    grabHandle.AddPolygon(points);
  }
 
  protected override void OnPaint(PaintEventArgs e)
  {
    base.OnPaint(e);
 
    Graphics g = e.Graphics;
    g.FillPath(pathBrush, grabHandle);
    g.DrawPath(pathPen, grabHandle);
  }
}
So far as I know, it appears to work just fine.

If you need to post a picture of what you expect, drawing something up (may I suggest the free Paint.NET[^] application from Washington University and Microsoft) and post it online. Surely you have a site somewhere where you can post a simple image. If not, you can email it to me but only as a last resort (and never continue a thread from this site personally - I get very irritated since this site contains wonderful forums). My email address you'll find in the automatic email notification message that gets sent to you when I reply to your post.

This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Sustained Engineering
Microsoft

[My Articles] [My Blog]
GeneralRe: GDI+ nonrectangular forms problem Pin
sstoyan22-Dec-04 9:00
sstoyan22-Dec-04 9:00 
GeneralRe: GDI+ nonrectangular forms problem Pin
Heath Stewart22-Dec-04 9:17
protectorHeath Stewart22-Dec-04 9:17 
GeneralRe: GDI+ nonrectangular forms problem Pin
sstoyan22-Dec-04 12:15
sstoyan22-Dec-04 12:15 
GeneralRe: GDI+ nonrectangular forms problem Pin
Heath Stewart22-Dec-04 13:39
protectorHeath Stewart22-Dec-04 13:39 
GeneralRe: GDI+ nonrectangular forms problem Pin
sstoyan22-Dec-04 22:19
sstoyan22-Dec-04 22:19 
GeneralRe: GDI+ nonrectangular forms problem Pin
Heath Stewart23-Dec-04 4:28
protectorHeath Stewart23-Dec-04 4:28 
GeneralRe: GDI+ nonrectangular forms problem Pin
sstoyan23-Dec-04 5:05
sstoyan23-Dec-04 5:05 
GeneralRe: GDI+ nonrectangular forms problem Pin
Heath Stewart23-Dec-04 5:29
protectorHeath Stewart23-Dec-04 5:29 
GeneralBinding DataGrid with Database Pin
T i T i20-Dec-04 21:50
T i T i20-Dec-04 21:50 
GeneralRe: Binding DataGrid with Database Pin
Heath Stewart20-Dec-04 22:13
protectorHeath Stewart20-Dec-04 22:13 
GeneralDisplay formatted xml document in richtextbox Pin
CNU20-Dec-04 20:50
CNU20-Dec-04 20:50 
GeneralTcpChannel and authentication Pin
Bjoern.adG20-Dec-04 20:39
Bjoern.adG20-Dec-04 20:39 
GeneralRe: TcpChannel and authentication Pin
Skynyrd20-Dec-04 21:06
Skynyrd20-Dec-04 21:06 
GeneralExtending Folder properties Pin
umeshb20-Dec-04 20:02
umeshb20-Dec-04 20:02 
GeneralRe: Extending Folder properties Pin
Heath Stewart20-Dec-04 21:58
protectorHeath Stewart20-Dec-04 21:58 
QuestionMultiligual and End-User defined labels...? Pin
Darren Weir20-Dec-04 18:35
Darren Weir20-Dec-04 18:35 
AnswerRe: Multiligual and End-User defined labels...? Pin
Sven Cipido20-Dec-04 20:29
Sven Cipido20-Dec-04 20:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.