|
Easily add WinXP themes to your applications without manifest! Just 5 lines of code!!!
|
Email
|
| Submitted on: |
10/26/2003 4:04:34 AM |
| By: |
Jorge Rodrigues Silva
|
| Level: |
Beginner |
| User Rating: |
By 27 Users |
| Compatibility: |
C#, VB.NET |
| Views: |
45925 |
|
|
|
|
|
This is a very simple way of add WinXP themes to your applications! Tired of carrying arround unwanted manifest files??? well this uses only 5 lines of code ;)
This article has accompanying files
|
 |
| |
Terms of Agreement:
By using this article, you agree to the following terms...
- You may use
this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
- You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.
- You may link to this article from another website, but ONLY if it is not wrapped in a frame.
- You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
|
Howto:
Correctly add WinXP themes to your Applications
Hello again!
This is a simple tutorial that shows what you have to do in order to have your
application running WinXP themes the correct way.
I've seen for a long time that people often use Manifest
files but that is not a solution, so check this out:
VB.NET
' ADD THIS LINE
OF CODE INSIDE THE
WINDOWS FORM GENERATED CODE
<System.STAThread()> _
Public
Shared
Sub Main()
System.Windows.Forms.Application.EnableVisualStyles()
System.Windows.Forms.Application.Run(New
frmDecode) ' replace frmDecode by the name of your
form!!!
End
Sub
And that's about everything!
Simple isn't it!!!
NOTE:
Some controls like buttons, checkboxes, radiobuttons, etc...
have a property called FlatStyle. In order to theme this control you must set
this property to System. Example:
button1.FlatStyle=FlatStyle.System
C#
// ADD THIS
LINE OF CODE INSIDE
static void Main()
System.Windows.Forms.Application.EnableVisualStyles();
System.Windows.Forms.Application.Run(new
Form1()); // replace Form1 by the
name of your form!!!
// IT WILL LOOK LIKE THIS:
[STAThread]
static
void
Main()
{
System.Windows.Forms.Application.EnableVisualStyles();
System.Windows.Forms.Application.Run(new
Form1());
// replace frmDecode by the name of your form!!!
}
And that's about everything!
Simple isn't it!!!
NOTE:
Some controls like buttons, checkboxes, radiobuttons, etc...
have a property called FlatStyle. In order to theme this control you must set
this property to System. Example:
button1.FlatStyle=FlatStyle.System;
Enjoy!!! & don't forget to check the file attached that
contains examples for both VB.NET and C#
Jorge Rodrigues @ 2003 Espinho, Portugal
|
|
Download article
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come
out every day, so no prevention program can catch 100% of them. For your own safety, please:
- Re-scan downloaded files using your personal virus checker before using it.
- NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
If you don't have a virus scanner, you can get one at many places on the net
including:McAfee.com
|
Terms of Agreement:
By using this article, you agree to the following terms...
- You may use
this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
- You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.
- You may link to this article from another website, but ONLY if it is not wrapped in a frame.
- You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
|
Report Bad Submission
|
Your Vote
|
| |
Other User Comments
|
10/26/2003 6:11:41 AM: Christopher Hemple
This Is Sweet! 5 Globes From Me! (If this comment was disrespectful, please report it.)
|
10/26/2003 8:03:40 AM: Zpage
Help me ! HOW I USE THIS???? (If this comment was disrespectful, please report it.)
|
10/26/2003 8:12:06 AM: Jorge Rodrigues Silva
zpage: try downloading the article as it is self-explanatory... you just have to add those 5 lines of code inside the Windows form generated code region! oh and a note that I forgot: This only works from VS.NET 2003 and beyond! VS.NET 2002 does not support this (If this comment was disrespectful, please report it.)
|
10/26/2003 2:30:01 PM: Zpage
OH, I only have Visual basic. Sorry, soon I will change to VB.net :D
greetz (If this comment was disrespectful, please report it.)
|
10/27/2003 3:20:20 AM: quartz
wowwwwwwwwwwwww cooooooooooool job dude hey can you do it for c sharp also (If this comment was disrespectful, please report it.)
|
10/27/2003 3:41:36 AM: quartz
hey but my icons in the tool bar (from image lists) are lost ? can you help ???? (If this comment was disrespectful, please report it.)
|
10/27/2003 5:57:21 AM: Jorge Rodrigues Silva
quartz: yes indeed the icons don't appear at all!! I'll see what I can do (If this comment was disrespectful, please report it.)
|
10/27/2003 10:58:24 PM: Chris Pietschmann, MCSD, MCAD
I tried this and it didn't work. I have VS.NET 2002. The EnableVisualStyles must be something that was added to the .NET Framework 1.1 (If this comment was disrespectful, please report it.)
|
10/28/2003 12:52:10 PM:
Excelente esta tua dica!!! Por acaso nao tens uma dica para colocar textboxes em context menus?
Mesmo que nao tenhas, obrigado na mesma (If this comment was disrespectful, please report it.)
|
10/29/2003 9:40:54 PM: Carl Mercier
This method is buggy and has been recommended not to be used by MS.
(If this comment was disrespectful, please report it.)
|
11/1/2003 1:05:31 AM: quartz
Application.DoEvents will solve the problem for icons in the Toolbar also works perfectly fine for C #
Application.EnableVisualStyles(); Application.DoEvents(); Application.Run(new MyForm());
Quartz (If this comment was disrespectful, please report it.)
|
11/20/2003 4:53:45 AM: Edson Ferreira
Muito bom Jorge, continua com o excelente trabalho ! (If this comment was disrespectful, please report it.)
|
12/2/2003 2:18:44 AM:
WOW! It works great!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Thankyou soooo much, ive been trying to do this for ages!!!!!! (If this comment was disrespectful, please report it.)
|
12/5/2003 12:23:06 AM:
That's nice but it works ONLY with .NET Framework 1.1!!!!! (If this comment was disrespectful, please report it.)
|
1/9/2004 9:48:51 PM: ka0z
and only with winxp (If this comment was disrespectful, please report it.)
|
1/22/2004 2:39:32 PM: Bayne
This is teh roxor! 5 circly thingies from moi. (If this comment was disrespectful, please report it.)
|
2/5/2004 10:51:59 PM: GravityFX
Excelent! 5 * from me :) (If this comment was disrespectful, please report it.)
|
2/16/2004 9:01:19 PM:
I tried your sample VB app however it did not work with my .net 1.1.4322. Whats up? (If this comment was disrespectful, please report it.)
|
2/25/2004 4:05:17 AM: l
hey it works fine, thank you to the one above me: do u have windowsxp ? ;) (If this comment was disrespectful, please report it.)
|
2/25/2004 7:26:14 AM: Jorge Rodrigues Silva
yes I have windows xp why?
(If this comment was disrespectful, please report it.)
|
3/10/2004 6:00:54 AM:
is only working if you haven't activated the windows classic style (If this comment was disrespectful, please report it.)
|
6/28/2004 5:37:35 PM:
Like Carl said before and I (painfully) learned it is better to use the manifest this method has multiple bugs. (If this comment was disrespectful, please report it.)
|
7/9/2004 3:17:15 AM:
is good... 5 * from me too.. if can show more example (If this comment was disrespectful, please report it.)
|
10/26/2004 12:39:44 AM: Aleksey Gladfish
!!!!!!!!!!IMPORTANT!!!!!!!!!! All this function does is stick a manifest file in the resource section of the app. I can do the same thing with resource hacker, that's what I have been doing for, uhmm...long time. I'm also working on an app that does this for you. A manifest is the real way to do it!!! Thank you very much. (If this comment was disrespectful, please report it.)
|
11/8/2004 4:13:11 AM: Nitin Bagga
great stuff!!!.....just that it doen't work when i put it in a MDI Child form.
Or maybe i'm doing something wrong....wouldn't mind help.
all the best (If this comment was disrespectful, please report it.)
|
11/9/2004 3:02:56 PM:
Cheers, ignore the losers talking about bugs etc. This is the only one that has properly worked for me, and manifests are nothing but complete hassle. (If this comment was disrespectful, please report it.)
|
12/20/2004 8:30:17 PM: Bill D
WOW, yea, 5 globes for me also, I am taking vb.net in school, and i am learning a tun of stuff, but for now mostly im creating a personal knowlege base, and this will deffinatly be in there. (If this comment was disrespectful, please report it.)
|
2/15/2005 8:20:36 PM:
Greate!! (If this comment was disrespectful, please report it.)
|
3/27/2005 6:07:27 PM: imageofgod
Thanks for sharing! (If this comment was disrespectful, please report it.)
|
5/13/2005 5:36:15 PM:
Hello to all. This is a great code. Yes, this is a great code and it is the pure contest winner. But please don't add this function to your code. It is really buggy, i can assure. Also Microsoft assure it. The special DoEvents function is a great way to try to make it working without bugs. But it does not works. I programmed a bot to launch a simple application with this code enabled(also with DoEvents) and over 10% times, within first 5 minutes, the application crashed. Hope this help. P.S. Great Code anyway. And sure the greatest code when Microsoft will solve BUGS. (If this comment was disrespectful, please report it.)
|
7/2/2005 5:23:08 AM:
Cool!! Thx! (If this comment was disrespectful, please report it.)
|
9/15/2005 1:13:06 PM: Mike
No working!!! (If this comment was disrespectful, please report it.)
|
4/22/2006 12:48:17 PM: Sam C.
this feature is integrated into the vb.net aplication. project>>>Properties>>>Enable XP visual Styles (If this comment was disrespectful, please report it.)
|
10/6/2008 11:34:13 PM: winst0n
enable xpvisualstyles are already included in 2005 2008 versions of visual studio, thanks for helping anyway......... (If this comment was disrespectful, please report it.)
|
Add Your Feedback
Your feedback will be posted below and an email sent to
the author. Please remember that the author was kind enough to
share this with you, so any criticisms must be stated politely, or they
will be deleted. (For feedback not related to this particular article, please
click here instead.)
To post feedback, first please login.
|