sk**********@yahoo.com wrote:
I've created an application for Windows XP but I'm having trouble
getting the right "look". I'd like my application to look somewhat
like the Windows Vista sidebar:
http://www.winsupersite.com/showcase...gallery_01.asp
Notice how there is a black to transparent gradient on the right side
of the screen. Does anyone know any way acheive this effect using
Visual Studio 2005?
Sure.
1) Create the appropriate gradient in the Loaded event:
private void Form1_Load(object sender, EventArgs e)
{
Rectangle Client = ClientRectangle;
Bitmap Background = new Bitmap(Client.Width, Client.Height);
using (Graphics G = Graphics.FromImage(Background))
{
using (Brush B = new LinearGradientBrush(Client,
Color.FromArgb(0, Color.Black), // left transparent
// You may want more or less transparency on the right
Color.FromArgb(200, Color.Black), // right nearly opaque
LinearGradientMode.Horizontal))
{
G.FillRectangle(B, Client);
}
}
BackgroundImage = Background;
}
2) Override OnPaintBackground to only paint the background
(ie, don't first fill with the BackgroundColor):
protected override void OnPaintBackground(PaintEventArgs e)
{
if (BackgroundImage != null)
e.Graphics.DrawImage(BackgroundImage, ClientRectangle);
}
--
..NET 2.0 for Delphi Programmers
www.midnightbeach.com/.net
Delphi skills make .NET easy to learn Great reviews & good sales.