Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
i have this non rectangular window (spline-shaped) :



using System;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace Guitar
{
    class GuitarForm : Form
    {
        Bitmap bmp;
        GuitarForm()
        {
            
          //  this.FormBorderStyle = FormBorderStyle.None; 
            bmp = new Bitmap("C:\\ok.jpg");
            GraphicsPath gp = new GraphicsPath();

           
            Point[] curves = new Point[]{
new Point(93,99), new Point(200, 55),
new Point(328, 128),new Point(450,100),new Point(560,200),
};
            gp.AddCurve(curves);
            gp.AddLine(560,200, 560, 500);
            gp.AddLine(560, 500, 93, 500);
            gp.AddLine(93, 500, 93, 99);
            gp.CloseFigure();




            this.Region = new Region(gp);
        }

        protected override void OnPaint(PaintEventArgs ea)
        {
            base.OnPaint(ea);
            Graphics g = ea.Graphics;
            g.DrawImage(bmp, new Point(0, 0));
            Rectangle scaled = new Rectangle(20, 20, 60, 60);
            g.DrawImage(bmp,scaled);
            g.DrawRectangle(Pens.Red, scaled);
            Point[] pGram = new Point[]{
new Point(50, 10),
new Point(100, 30),
new Point(20, 100),
};
            g.DrawImage(bmp, pGram);
        }


        public static void Main()
        {
            Application.Run(new GuitarForm());
        }

    
        private void InitializeComponent()
        {
            this.SuspendLayout();
            // 
            // GuitarForm
            // 
            this.ClientSize = new System.Drawing.Size(560, 560);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.Name = "GuitarForm";
            this.ResumeLayout(false);

        }
      
    }///:~
}





the problem is that when i run it, only one part of the window appears and i have to drag to brders in order to see the whole shape . Is there any way it can run all-ready sized the way i want it ?
Posted
Updated 1-Jun-10 3:57am
v2

1 solution

Could it be something as simple as this.Size = ...?

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900