Reader Level:
Articles

Interactive Shaped Forms

By Jibin Pan on November 29, 2001
This Demo show how to create shaped form and customized buttons using Region, GraphicsPath and picture control and using picture control to play animate pictures.
  • 0
  • 0
  • 11347
Download Files:
 

This Demo show how to create shaped form and customized buttons using Region, GraphicsPath and picture control and using picture control to play animate pictures.
ShapedFormImgJP.jpg

All the graphic is get from Microsoft Media Player and change the size that make the graphic files smaller.

The procedures:

  1. Create a form with some background color, then set the property TransparenceKey to that color and set the FormBorderStyle to None.

  2. Override the Form_Paint function. You can do it by protected override void  OnPaint(PaintEventArgs e)
    or add a new Handler

    this.Paint += new System.Windows.Form.PaintEventHandler(Form_Paint)

  3. Using Region and GraphicsPath to set the Region that you want to display.

im = new Bitmap("mediaPlayer.jpg");
private void Form_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
Rectangle mainRect =
new Rectangle(0, 0, 695, 278);
Region mainRegion =
new Region(mainRect);
e.Graphics.SetClip(mainRegion, CombineMode.Replace);
// Create a GraphicsPath object and add a curve.
GraphicsPath myPath = new GraphicsPath();
.........
Region ExcludeRegion3 =
new Region(myPath);
e.Graphics.ExcludeClip(ExcludeRegion3);
......
e.Graphics.DrawImage(im, 0, 0, 495,278);
// Reset clipping region to infinite.
e.Graphics.ResetClip();
}

Note: Keep all the graphics in the bin/debug directory.

Jibin Pan

Jibin Pan is vc++, c programmer at Interactive Edge Corp. Xtend Communications Corp. MoneyLine Corp in new york city since 1994 and has Master degree at computer science.

COMMENT USING

Trending up