Problems supporting Windows XP themes

  • Thread starter Thread starter Roy Chastain
  • Start date Start date
R

Roy Chastain

It appears that these two lines of code are required to support Windows XP themes.

Application.EnableVisualStyles();
Application.DoEvents(); // this corrects a bug in EnableVisualStyles()

The problem is that on systems prior to XP sometimes this works okay and other times it aborts because UXTHEME.DLL is not found.
I realize that UXTHEME.DLL is an XP dll.

What is the correct action to prevent problems on Win 2K and below?

Thanks
 
Hi ,

From your description, your program can not run on windows 2k system, the
error message shows it can not find uxtheme.dll. Did I understand your
problem correctly?
Base on my research, if you only use EnableVisualStyles in your program to
enable XPTheme, you should not meet this problem, since in the method it
will check the OS version before loading the dlls needed.
I suggest you test it by making a new winform application, adding the
EnableVisualStyles method, and a System.Windows.Forms.Button control(set
FlatStyle=System), then test it on a w2k system to see if you would still
have this error.

If the test program works correctly, I suggest you checking the controls
used in your project, there might be some controls which use uxtheme.dll
via P/Invoke.

If the test program still have the same error message, it's not a correct
behavior, please send this test sample project in zip file (with the
generated exe file) to me by e-mail. I'll take a look at it.

Good Luck!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft community Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.
 
Yes, you understood correctly.

The test works correctly. I need to understand more about the process to have any chance of fixing it.

Since EnableVisualStyles is called before Application.Run, I assume that it should not matter what is on the form etc. (Please
note the error is in the call of EnableVisualStyles, not later when the form is displayed.)

I have 2 programs that exhibit the problem. One of them has never worked on a 2k system with the call to EnableVisualStyles
present. The other worked for over 1 month and then quite working. (Program still in debug stage so it was compiled many times
each day.)

What could affect the program that would cause it behavior to change from working to not working? This appears to be some sort of
random error.

FYI. We have no third party controls. I just searched ALL of our .NET code for PInvoke and uxtheme. Neither of them are present
in our code.


Hi ,

From your description, your program can not run on windows 2k system, the
error message shows it can not find uxtheme.dll. Did I understand your
problem correctly?
Base on my research, if you only use EnableVisualStyles in your program to
enable XPTheme, you should not meet this problem, since in the method it
will check the OS version before loading the dlls needed.
I suggest you test it by making a new winform application, adding the
EnableVisualStyles method, and a System.Windows.Forms.Button control(set
FlatStyle=System), then test it on a w2k system to see if you would still
have this error.

If the test program works correctly, I suggest you checking the controls
used in your project, there might be some controls which use uxtheme.dll
via P/Invoke.

If the test program still have the same error message, it's not a correct
behavior, please send this test sample project in zip file (with the
generated exe file) to me by e-mail. I'll take a look at it.

Good Luck!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft community Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.
 
Hi Roy,

"Please note the error is in the call of EnableVisualStyles, not later when
the form is displayed. "

If I understand correctly, you mean you got this message when calling the
EnableVisualStyles method, is it from an exception?
If yes, maybe we can get some information from the stack trace of the
exception.

If there is not much helpful information, is it possible to send me a
sample to let me test it on my system?

Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft community Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.
 
Well, today it is working. I put the EnableVisualStyles back into the program that it had worked in and it is working as of now.
Next time it fails, I will get the stack trace and post into a new message. (Don't know how long it will take before it fails
again.) Also, I will see if the simple test program fails at that time also.

Hi Roy,

"Please note the error is in the call of EnableVisualStyles, not later when
the form is displayed. "

If I understand correctly, you mean you got this message when calling the
EnableVisualStyles method, is it from an exception?
If yes, maybe we can get some information from the stack trace of the
exception.

If there is not much helpful information, is it possible to send me a
sample to let me test it on my system?

Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft community Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.
 
The program worked for 3 compiles and then after the 4th compile it failed again.

The exception is DLL not found

Here is the stack trace.

system.windows.forms.dll!System.Windows.Forms.OSFeature.GetVersionPresent(System.Object feature = {System.Object}) + 0x10b bytes
system.windows.forms.dll!System.Windows.Forms.FeatureSupport.IsPresent(System.Object feature = {System.Object}, System.Version
minimumVersion = {System.Version}) + 0x13 bytes
system.windows.forms.dll!System.Windows.Forms.FeatureSupport.IsPresent(System.Object feature = {System.Object}) + 0x32 bytes
system.windows.forms.dll!EnableThemingInScope.EnableThemingInScope(bool enable = true) + 0x3f bytes
system.windows.forms.dll!ThreadContext.RunMessageLoop(int reason = 0x2, System.Windows.Forms.ApplicationContext context =
HGSConfigUtility.exe!KMS.HGS.Forms.ConfigUtility.ConfigUtility.Main(string[] args = {Length=0x0}) Line 1116 C#

The test program is still working, but I have not recompiled it.


Hi Roy,

"Please note the error is in the call of EnableVisualStyles, not later when
the form is displayed. "

If I understand correctly, you mean you got this message when calling the
EnableVisualStyles method, is it from an exception?
If yes, maybe we can get some information from the stack trace of the
exception.

If there is not much helpful information, is it possible to send me a
sample to let me test it on my system?

Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft community Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.
 
Hi Roy,

Thanks for your reply,
The stacktrace did give some information for this issue, it helped us
narrow down this issue a bit. From the stack trace, the exception is
actually thrown out in DoEvents method. But we still need more information
to investigate it further.
I'd like first to confirm, if you got this exception only running in VS.NET
IDE or got it even in running stand alone (without debugger)?
If this is only happened when running with debugging in IDE, maybe you need
check if you enabled catching the first-chance exception in your
"Debug"->"Exception" settings. If this is a first-chance exception, would
your program continue to run if you choose "Continue"?

If the exception is also thrown when running stand alone. please send me a
sample to reproduce this problem, I'll forward it to the product group to
let them take a look at it.

Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft community Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.
 
It has failed outside of the debugger. Today it is working outside of the debugger.

In the debugger, I get 2 first chance exceptions and yes, if I click continue, things continue and the program runs.

Since I don't know when it will fail outside of the debugger again, I will start a new thread when it does.

Thanks for your help.

Hi Roy,

Thanks for your reply,
The stacktrace did give some information for this issue, it helped us
narrow down this issue a bit. From the stack trace, the exception is
actually thrown out in DoEvents method. But we still need more information
to investigate it further.
I'd like first to confirm, if you got this exception only running in VS.NET
IDE or got it even in running stand alone (without debugger)?
If this is only happened when running with debugging in IDE, maybe you need
check if you enabled catching the first-chance exception in your
"Debug"->"Exception" settings. If this is a first-chance exception, would
your program continue to run if you choose "Continue"?

If the exception is also thrown when running stand alone. please send me a
sample to reproduce this problem, I'll forward it to the product group to
let them take a look at it.

Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft community Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.
 
Back
Top