Strange "bug" on EnableVisualStyles?

  • Thread starter Juan Pedro Gonzalez
  • Start date
J

Juan Pedro Gonzalez

I am a bit unsure about this "Effect"... My code:

Public Sub Main()
Application.EnableVisualStyles()
Application.DoEvents()

Dim myMainForm As New FormularioPrincipal

Dim mySplash As New MyClass.SplashScreen
If mySplash.ShowDialog() = DialogResult.OK Then
Application.Run(myMainForm)
End If
End Sub

Visual styles are not enabled in any place on the whole application. However
an external manifest is able to enable visual styles.

With this Code:

Public Sub Main()
Application.EnableVisualStyles()
Application.DoEvents()

Dim myMainForm As New FormularioPrincipal

'Dim mySplash As New MyClass.SplashScreen
'If mySplash.ShowDialog() = DialogResult.OK Then
Application.Run(myMainForm)
'End If
End Sub

Visual Styles get enabled.

MyClass is a class library wich contains a Windows Form used for the splash
screen of several applications.

I've used this kind of coding before with no problems... Can't even imagine
what could be going wrong. Anyone has faced this problem before?
 
J

Juan Pedro Gonzalez

Humm "solved" it on my own... Although I don't really know whats happening,
so any Ideas are welcomed.

On my SplashScreen I've got a Timer in order to show it up (Otherwise it
would just flicker). I've added the next two lines after the timer has
stopped:

Windows.Forms.Application.EnableVisualStyles()
Windows.Forms.Application.DoEvents()

This code is included on the Class Library wich contains the Windows Forms.
Now both the splash screen and the application get Visual Styles Enabled,
but it seems quite strange that the usual way (Inside the application Sub
Main) won't do the job.

Best Wishes
 
C

Charles Law

Hi Juan

There is a problem with EnableVisualStyles in the current version (2003) of
..NET, but not particularly the one you have identified. I can't remember
off-hand what the error message is, but the current recommendation is to use
an external manifest. If you do not you are likely to get intermittent
problems in you application, even with the DoEvents immediately after.

HTH

Charles
 

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