Windows Form look

lothos12345

Junior Contributor
Joined
May 2, 2002
Messages
294
Location
Texas
I need to change the way a windows form application looks. It needs to look more like an XP windows application, with the bubbly look that XP has, also I was wondering if anyone can recommend me a site for looking for professional icons. As always any help is greatly appreiciated.
 
If you are using the .NET Framework 1.1 then the Application.EnableVisualStyles will ensure that the controls on your forms mimic the XP look. Simply place this in a Sub Main or inside your startup form:

Visual Basic:
Application.EnableVisualStyles()
'Calling doevents removes a small bug that disables
'images from being displayed inside list and tree controls
Application.DoEvents()

In terms of icons, if your looking for the ones that XP uses then you could always extract them from the Shell32.dll file

Hope this helps
 
It did not work

My application does not have the xp-style look. I put the code in the load event of my VB code. I am running the Framework 1.1, does it matter that I am running Windows 2000 Professional as an operating system. As always any help given is greatly appreciated.
 
lothos12345 said:
My application does not have the xp-style look. I put the code in the load event of my VB code. I am running the Framework 1.1, does it matter that I am running Windows 2000 Professional as an operating system. As always any help given is greatly appreciated.
If you mean the Form_Load event, I believe that is 'too late' in the creation of the form or something, but don't quote me on that :P

If you put Application.EnableVisualStyles() after the line "InitializeComponent()" in the Windows Form Designer Generated Code, it should work fine.

Also remember that certain controls (such as buttons) need to have their FlatStyle property set to "System" for them to use XP styles.

Hope that helps :)

Edit: Oops, I forgot that you're running Win2k. Unfortunately you cannot get XP styles that simply on non-XP operating systems. I think you may need to find/make a custom control. Sorry I didn't notice that before I posted :(
 
Still not working

It still did not work, do you think the problem is that I am trying too run this program in a Windows 2000 Professional environment. Any help is greatly appreciated.
 
First of all Windows 2000 does not support visual styles, so it won't render any visual style layers onto your controls.

Second of all do not use the Application.EnableVisualStyles() call, because it causes numerous problems, it's a buggy method. Stick with the manifest file for now, i think they rectified this issue in Whidbey.
 
You can get the Windows XP look in a Win2K environment with custom user controls. It's a bit of work, but it guarantees the the end user will see the same interface no matter what OS they are using.
 
Okay, there is a lot of misinformation about the .EnableVisualStyles method here. First of all, no, Windows does not offer Xp styles on Windows 2000, even if you call EnableVisualStyles. Windows only offers Xp styles in Xp. Like DiverDan said, you need to use custom controls, or something other than OS or .NET rendered controls (maybe you can just make owner drawn buttons....). If the user is using Windows Xp (regardless of which OS you are developing in), EnableVisualStyles will work JUST FINE. You just need to know when and how to use it. NOT after InitializeComponents. NOT in the Form.Load event handler. It must be called before ANY controls are created, preferably in Sub Main. Add this into your main form's code:

Visual Basic:
Public Shared Sub Main
    Application.EnableVisualStyles() 'Xp styles, LIKE MAGIC!
    Application.DoEvents() 'EnableVisualStyles bugs gone, LIKE MAGIC!
    Application.Run (New FrmMain) '<--Replace FrmMain with the name of your main form class
End Sub

If you already have a public sub main just insert the first two lines from the sub main shown above into your sub main. I have never had any problems with EnableVisualStyles. Maybe if you are subclassing the windows controls or directly handling the windows messages it could change some behavior that could cause you problems. Most likely not though.

Give it a whirl. If exceptions start getting thrown it is easy enough to fix, just remove the five lines of code, no worries. Keep in mind that you won't see any difference since you are using Windows 2000. Any of your users running Windows Xp will see the difference.

As far as Icons go, I draw my own ARGB icons in photoshop and save them with a plugin called IconFactory (IconFactory is not free).

[Edit]A manifest would certainly also work, but it requires that the additional .Manifest file be present in the folder that the exe is in. The "Visual Studio .NET 2003 Combined Collection" help files include a good example.[/Edit]
 
If you want to be consistent with the OS, use xp styles. If you are going for a complete skin, like media player, then by all means use custom controls.
 
I have been looking into exsacually the same thing, trying to give an XP style to my application, no matter which OS I am using. I have found a third-party piece of software called dotnetbar http://www.devcomponents.com/dotnetbar/ that I am currently evaluating and it seems to be very good visually and coding wise. The only thing I have found is that it does slow the display of your form by about a sec. You can download a trial version and the license to distribute with your software (royalty free) is $189.

Let me know what you think? and I would also be interested to hear good or bad points about this software.

Cheers

Simon
 
If it is worth the one second wait and the $189 to you, go for it. It looks like its easy to use in your application. Personally, I don't pay for anything. If I can't get something for free or make it myself, I just forget about it. But that's probably not always the best policy. I personally also can't stand waiting for a program's window to open after I click the Icon. The faster, the better. But thats just me.
 
You could also respect the users preferences and only use the native skinning (where applicable) instead of forcing them to use a Luna interface. I'm still using win2k and any program that tried to force a Luna interface on me is isn't getting opened a second time if i can help it. You'd have to have a _really_ good reason to ignore user preferences and get away with it.
 
The "classic windows" interface is considered by many to be the ugliest operating system around. Thats why windows xp introduced us to visual styles, and thats why so many applications, including some of Microsofts own programs (think Media Player, messenger) are skinned.

Besides that, a skin can give a program distiction and set it apart from other programs, and in some cases can improve or modify functionality. Are these good enough reasons?

Granted some skins just make an app more confusing or cluttered looking, but skins are fine when used appropriately. If you are making a simple or small program, there isn't much need to toss a skin on there. When used with descretion and implemented well, however, a skin can be a good thing.
 
Well thank God we all have our individual opinions. But I've got to say that it sounds like you guys are trying to "sell or force" yours on others......Adobe, Symantec, Corel and a bunch of others do not use the XP OS shell for their forms and controls and I for one am happy about that.
 
As I said I'm only looking into using it at the moment (don't want to get into pros and cons issues) but one issue that I am worried about is the time delay. As marble eater said and I agree with, I want forms to appear instantanuosly when requested. Is there anyway I can load my forms into memory or something (I'm new to vb.net) when the application is initially loading, so when the forms are requested they don't have this time delay as they are already ineffect loaded / built.

I don't know if this is possible and my terminoligy is probably all wrong, so please be gentle
 
If you think the classic interface is ugly thats fine, i'll stick with it though because i like it, we're both happy. The moment you start forcing one interface on people though you're in dodgey territory. One thing you should appreciate about the windows interface (skinned or not) is that it is designed to be consistant, and it is remarkably so. The guidelines show you how to write programs that confirm to standard usage patterns, thing slike copy paste, file and edit menus, they're standard only because if you put them somewhere else or use different names or accessor keys you will confuse your users.

If you force people to use a skinned application you blow away any previous experience they have and force them to learn your program as a separate system. This means that people will use your program slowly and relcutantly if they continue to use it at all. You should try to make your program as familiar as possible and conform to user preferences whereever possible to minimize the new ideas that users need to know.

Microsoft and other may well be skinning their applications, but i'm not using them and i hate skinned applications that don't let me use a classic theme. I don't have resources to space and i don't need irritating applications taking it upon themselves to ignore my preferences and wasting my resources.

By all means skin things, make sure that if people are using Luna or some other skin that your application matches and makes the experience as easy as possible. But don't force skin to a new look/paradigm, thats just silly.
 
I don't know if this will work but try instantiating but not showing the form as soon as you know that you will need it. If, for example, you know that a dialog that you created will be used frequently, instantiate it when the app loads. Declare a variable initialized to a reference of a new instance of this form (like Dim frmEntryEditor as new EntryEditor). The form will be initialized, but not shown until you call frmEntryEditor.Show(). There is no way, of course, to do this for your main form.
 
If you initiate an instance of the Form2 from Form1's declaration section, you will also have to Hide Form2 in Form2's closing event. Not knowing if you need to update any variables in Form2 from Form1, this method of showing Form2 will require the use of Public events in Form2 for updates....I think I made that sound very confussing!
 
Back
Top