How to enable a common control in a Windows application

I am trying to enable general controls in an application. I followed the steps in this MSDN article , specifically the section Using ComCtl32. dll version 6 in an application that uses only standard extensions . But I can’t make it work.

The only thing I do, unlike the article, is that I add manifest information to the Project Properties Pages | Configuration Properties | Linker | Manifest file | Additional manifest dependencies . This is what I entered in the text box:

"type = 'Win32' name = 'Microsoft.Windows.Common-Controls' version =' 6.0.0.0 'processorArchitecture =' * 'publicKeyToken =' 6595b64144ccf1df 'language =' * 'xmlns =' http://schemas.microsoft. com / developer / msbuild / 2003 '";% (AdditionalManifestDependencies)

When I check the generated manifest (MyApp.exe.intermediate.manifest), it looks right.

I also add a link dependency to ComCtl32.lib in Project Properties | Configuration Properties | Linker | Login | Additional dependencies . I also call InitCommonControlsEx when starting with initializing the INITCOMMONCONTROLSEX structure as follows:

INITCOMMONCONTROLSEX icex; icex.dwSize = sizeof(INITCOMMONCONTROLSEX); icex.dwICC = ICC_STANDARD_CLASSES; 

But calling InitCommonControlsEx always returns FALSE (which means that it did not work). After some investigation, it turned out that the error code returned from GetLastError was ERROR_FILE_NOT_FOUND. What could be the problem?

UPDATE: I noticed something that might be due to a "file not found" error. When I launch the application from the debugger, one of the lines in the Output window:

"MyApp.exe": loaded "C: \ Windows \ winsxs \ x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.6002.18305_none_88f3a38569c2c436 \ comctl32.dll ', cannot find or open the PDB file

However, there are a few similar lines for some of the more standard libraries, such as kernel32.lib, user32.lib, etc.:

"MyApp.exe": loaded "C: \ Windows \ System32 \ ntdll.dll", cannot find or open PDB file

"MyApp.exe": loaded "C: \ Windows \ System32 \ kernel32.dll", cannot find or open the PDB file

"MyApp.exe": loaded "C: \ Windows \ System32 \ msvcrt.dll", cannot find or open PDB file

"MyApp.exe": loaded "C: \ Windows \ System32 \ user32.dll", cannot find or open the PDB file

These lines are always displayed for any application, and this does not cause problems. Could it be different for ComCtl32.dll?

+7
source share
2 answers

OK I did my homework and discovered something new. As I ended up getting this to work, it was almost what you are trying to do:

  • Go to Project / Properties / Linker / Manifest File / Additional Manifest Dependencies
  • Enter the following verbatim text (which means all single and double quotes are exactly the same as shown below). It's all on one line, by the way.

    "type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'"

  • Save your settings and run the FULL project (if not a solution) to restore the manifest and regenerate PCH.

Before that, the following was on my download list:

Loaded "C: \ Windows \ WinSxS \ x86_microsoft.windows.common-controls_6595b64144ccf1df_ 5.82.7601.17514 _none_ec83dffa859149af \ comctl32.dll

After the hand-forcnig version of the manifest for common controls, the download list now includes this (and TRUE responds correctly to InitCommonControlsEx() , which is the point of all this in the first place):

Loaded "C: \ Windows \ WinSxS \ x86_microsoft.windows.common-controls_6595b64144ccf1df_ 6.0.7601.17514 _none_41e6975e2bd6f2b2 \ comctl32.dll

Note: you can also do this using the original #pragma in the source code, ideally in your stdafx.h header, but I prefer it that way.

Hope this helps.

+10
source

No, PDB file warnings are there to tell you that you do not have debug information for the Windows system DLLs. Getting a FALSE return from InitializeCommonControlsEx () is, of course, a key issue.

Something is wrong with the used string of additional manifests. For some time I did this, but could not find a flaw. It is often easier to specify linker options in the source code. Everything was fine when I used:

 #include <CommCtrl.h> #pragma comment(lib,"comctl32.lib") #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") 

Just copy and paste the specified code snippet into one of your source files.

+8
source

All Articles