Thursday, 28 April 2011

Change Form Shape in Win Forms



Change Form Shape in Win Forms



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication3
{
    public partial class Form1 : Form
    {
        int intPosition = 0;
        String strScrollText = "This is scroll text";

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            timer1.Enabled = true;
            timer1.Interval = 200;
            this.Refresh();

        }

        private void button1_Click(object sender, EventArgs e)
        {
            Form f = new Form();
            f.Height = 350;
            f.Width = 350;
            f.BackColor = Color.Red;
           // f.TransparencyKey=;

            //Creating circle path
            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
            path.AddEllipse(10, 10, 300, 300);

            //Creating the region from the circle path
            f.Region = new Region(path);

            f.Show();
        }

        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            timer1.Enabled = false;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if(intPosition <= strScrollText.Length)
            {          
                //intPosition = 0;
                this.Text = strScrollText.Substring(intPosition);
                intPosition = intPosition + 1;
            }
        }
    }
}

No comments:

Post a Comment