473,395 Members | 1,468 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Visual Studio 2005 Form Gradient

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?

Sep 20 '06 #1
2 1860
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.
Sep 20 '06 #2
Jon Shemitz wrote:
1) Create the appropriate gradient in the Loaded event:
I *meant* the Layout event. ;-)
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);
}
Alas, it's nowhere near this easy. This approach doesn't handle
changes to the background (ie, if you minimize a window that's under
this gradient window, the background under the gradient doesn't
change) AND the background isn't drawn properly under, say, a
transparent label.

--

..NET 2.0 for Delphi Programmers www.midnightbeach.com/.net
Delphi skills make .NET easy to learn Great reviews & good sales.
Sep 21 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Charts | last post by:
6/23/05 ..NET Development\Framework\dotnet.framework.aspnet Visual Studio 2005 Beta 2 project cannot work in IIS virtual directory I used Visual Studio 2005 Beta 2 to build a simple new...
1
by: Mattias | last post by:
Hi I have The new Visual Studio 2005 Professional installed, I have created a vb project as windows application and receive a perculiar error when trying to open the Form designer. "Microsoft...
0
by: fiona | last post by:
Innovasys Ltd., a leader in help authoring and documentation tools, today announced the inclusion of a tailored version of the Innovasys HelpStudio help authoring product, HelpStudio Lite, in the...
3
by: nkarnold | last post by:
My application seems to be ignoring Enable XP visual styles, which is ticked on in the application properties. the Toolbar and Menubar, which appear the nice looking shaded blue appear like that...
2
by: Hunk Gym | last post by:
VB.Net of Visual Studio.Net 2003 VS Visual Basic 2005 Express Edition Good Day! Would be appreciate if there is solution for the following problem: - In VB.Net of Visual Studio.Net 2003,...
8
by: WT | last post by:
Is it normal that Visual Studio sets the PreInit handler for a Page from the OnInit code ? No chance to fire it as OnPreInit is run befor OnInit. ??? CS
3
by: Edwin Smith | last post by:
I have a 2 form project in VS2005 that now hangs whenever I try to do anything with the second form. This seems to have started when I added some SQL tables from a Pervasive v.9 database using the...
1
by: johnlim20088 | last post by:
Hi, Currently I have 6 web projects located in Visual Source Safe 6.0, as usual, everytime I will open solution file located in my local computer, connected to source safe, then check out/check in...
1
by: cnixuser | last post by:
Hello, I am having a problem that I believe is related to the way a stream reader object looks for a text file by default. What I am doing is using a StreamReader object to read the text of a text...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.