XP Styles in vb.net 2003?

T

Terry Olsen

Is there a way to turn on XP Styles in 2003? Or is the manifest file still
the way to go?
 
B

Bernie Yaeger

Hi Terry,

It's pretty simple. Place this in the sub new of the start class of the
app:
MyBase.New()

Application.EnableVisualStyles()

Application.DoEvents()

Then designate all checkboxes, command buttons, radio buttons flatstyle
property to 'system'.

This will allow all pc's running xp to see all of your controls with xp
styles.

HTH,

Bernie Yaeger
 
T

Terry Olsen

This works also...but why does the MSDN tell you to put it in Sub Main and
then run Form1 from there?
 
B

Bernie Yaeger

Hi Terry,

I guess they are making an assumption about your start class.

Bernie
 
J

Jay B. Harlow [MVP - Outlook]

Bernie,
Rather then inside the sub new, I would strongly recommend putting this in
the Sub Main of your start class as the other suggest.

Public Class MainForm
...

Public Shared Sub Main()
Application.EnableVisualStyles()
Application.DoEvents()
Application.Run(New MainForm)
End Sub

End Class

For four major reasons:
1. Its not hidden in the construtor, which may be modified by the forms
designer.
2. It allows you to easily add any Global Exception Handlers at the same
time.
3. It allows you to customize the Application.Run itself (splash screens,
login dialog & such)
4. Its how most samples show it (consistency).

It has nothing really to do with "they are making an assumption about your
start class" per se. (as MainForm is going to be the start object in both
cases).

Hope this helps
Jay
 
T

Terry Olsen

Why is the "DoEvents" needed? It seems to work okay without it...or am I
missing something?
 
J

Jay B. Harlow [MVP - Outlook]

Terry,
Selected controls (toolbars for example) do not always display correctly if
you call EnableVisualStyles without the DoEvents (yes a bug).

Hope this helps
Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top