![]() |
Languages »
C# »
Windows Forms
Intermediate
Interactive Shaped FormsBy Jibin PanThis Demo show how to create shaped form and customized buttons using the Region, GraphicsPath and picture class |
C#, Windows, .NET 1.0, Dev
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||

This Demo show how to create shaped form and customized buttons using the Region, GraphicsPath and picture class. It also demonstrates using the picture control to display animated pictures.
All graphics are from Microsoft Media Player and have been resized to make the graphic files smaller.
TransparenceKey to that color and set the FormBorderStyle to None.
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)
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.
If you have any comments, I would love to hear about it. You can reach me at Jibin Pan.
| You must Sign In to use this message board. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 19 Mar 2002 Editor: Chris Maunder |
Copyright 2002 by Jibin Pan Everything else Copyright © CodeProject, 1999-2009 Web15 | Advertise on the Code Project |