tags:

views:

594

answers:

2

We've just recently switched our C++ MFC Application from VS2005 to VS2008. Unfortunately in doing so our UI has appearance problems, with things like group boxes appearing blue rather than black, properties dialogs having a white background etc. I presume that in VS2008, MFC has been changed to respect the OS theme (in my case XP default theme). Unfortunately, changing all our controls and our custom toolbars to make the app look decent again is going to require a lot of work.

So, does anyone know if there is a way in code to put the app back in VS2005 mode? I found the following code

typedef void (WINAPI *tSetThemeAppProperties)(  DWORD );

tSetThemeAppProperties pSetThemeAppProperties=0;
HINSTANCE  handle  = ::LoadLibrary("UxTheme.dll");

if (handle) 
    pSetThemeAppProperties = (tSetThemeAppProperties) ::GetProcAddress(handle,"SetThemeAppProperties"); 


if ( pSetThemeAppProperties)
{
    // call function
    pSetThemeAppProperties(0/*dwFlags*/);
}
::FreeLibrary(handle);

Which does stop the XP theme being picked up, but turns off ALL themes and leaves the application looking more dated than it did in VS2005.

thanks

+2  A: 

It may be that VS2008 is including a Manifest file in the project that loads the version 6.0 comctl32.dll rather than the 5.82 comctl32.dll... both ship with Windows XP and newer.

R. Bemrose
Hi there, I checked our manifest file and there was a reference to commctl32 v6 which wasn't in our vs2005 manifest. I removed this and it made no difference. I tried to reference v5.82 of the comctl32.dll but my app doesn't start. Have you got an example manifest (version/publickeytoken info)?
Unfortunately, I don't. I don't usually use C++. I've only dealt with manifest files after converting something from Java to a compiled executable on a client's request, and the compiled version ended up with the older comctl32.dll loaded when it should have had the newer one.
R. Bemrose
You should check your `stdafx.h` file. The manifest reference can also be found there. You can try changing the manifest version, but there's a `publicKeyToken` that I guess will also have to be changed.
djeidot
+1  A: 

Under "Properties->Configuration Properties->Linker->Manifest File", set the "Generate Manifest" option to "No".

Then add your own manifest file if you like, and set it under "Properties->Configuration Properties->Manifest Tool->Input and Output", "Input Resource Manifest".

Just make sure that if you add your own manifest file that it doesn't contain the reference to commctl32 v6.

Stefan