Common controls manifestdependency in stdafx.h  
Author Message
MikeBzz





PostPosted: Visual C++ General, Common controls manifestdependency in stdafx.h Top

If I create an MFC application with VS 2005 App Wizard then it puts the following into stdafx.h:

#ifdef _UNICODE
#if defined _M_IX86
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_IA64
.. etc.
#endif
#endif

The effect of this is that a Unicode app gets the XP look and a non-Unicode app doesn't. If I remove the #ifdef _UNICODE then the non-Unicode app gets the XP look. So why is the #ifdef _UNICODE in there

I have a large non-Unicode app (it will become Unicode in time, but not just now) which I would like to give the XP look but am concerned that I'm storing up trouble by modifying bits of auto-generated code.

On the same subject, the App Wizard also puts this code fragment into the app's InitInstance() method:

// InitCommonControlsEx() is required on Windows XP if an application
// manifest specifies use of ComCtl32.dll version 6 or later to enable
// visual styles. Otherwise, any window creation will fail.
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize =
sizeof(InitCtrls);
// Set this to include all the common control classes you want to use
// in your application.
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);

If I remove this code fragment everything still works, so the statement Otherwise, any window creation will fail. is a wrong

Mike



Visual C++4  
 
 
Ted.





PostPosted: Visual C++ General, Common controls manifestdependency in stdafx.h Top

It's fine, I've been using XP look and feel in non-Unicode apps for years. However there are some things you should be aware of, like superclassing edit controls e.g. making a new window class based on the edit control but with a different class name (doesn't work well with comctl32.dll version 6). I think this is why they disable it by default. But in the years I've been using it, that was the only issue I had to fix in my code.

As long as comctl32.dll version 6 already gets loaded into your processes address space the call isn't necessary. However there are other classes you may want to register other than ICC_WIN95_CLASSES.


 
 
MikeBzz





PostPosted: Visual C++ General, Common controls manifestdependency in stdafx.h Top

Thanks Ted.

Mike


 
 
Zamboni





PostPosted: Visual C++ General, Common controls manifestdependency in stdafx.h Top

How do I work around grid controls that use SubclassDlgItem

We use an older Objective grid and newer Ultamate grid, but both use SubclassDlgItem.