1

I'm currently trying to work through the Windows GUI API and the more I see... let's come the the point: Basically i'm following this guide by msdn to enable the visual styles from Win7, but InitCommandcontrolsEx returns false: I'm doing the following:

Include the the headers

#include <windows.h>
#include <commctrl.h>

Initialize it with the desired visual styles

INITCOMMONCONTROLSEX icex;
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
icex.dwICC = ICC_STANDARD_CLASSES;
if(InitCommonControlsEx(&icex)) {
    cout << "Visual styles loaded" << endl;
} else {
    cout << "Error while loading visual styles" << endl;
    cout << GetLastError() << endl;
}

Create a resource file which will compile the manifest

CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "GUI.exe.manifest"

The manifest itself

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
    version="1.0.0.0"
    processorArchitecture="*"
    name="Company.Project.Name"
    type="win32"
/>
<description>Some Description.</description>
<dependency>
    <dependentAssembly>
        <assemblyIdentity
            type='win32'
            name='Microsoft.Windows.Common-Controls'
            version='6.0.0.0'
            processorArchitecture='*'
            publicKeyToken='6595b64144ccf1df'
            language='*'
        />
    </dependentAssembly>
</dependency>
</assembly>

For that, i'm using windres from GNU binutils

windres GUI.rc GUI.res

And finally, i link against it and ComCtl32.dll

g++ "-LC:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Lib\\x64" -mwindows -o GUI.exe "src\\main.o" -lmingw32 -lComCtl32 "src\\GUI.res"

But as mentioned in the introduction, InitCommonControlsEx always jumps into the false block, not showing the updated visual styles which proves the false. Any ideas?

System: Win7 64Bit g++ compiling 64Bit IDE Eclipse CDT

Matze
  • 533
  • 7
  • 16
  • Okay so what is the result of the `GetLastError` call? – Lightness Races in Orbit May 03 '15 at 01:36
  • @LightnessRacesinOrbit `0` – Matze May 03 '15 at 01:37
  • According to Dependency Walker, it takes the DLL from `C:\windows\winsxs\amd64_microsoft.windows.common-controls_6595b64144ccf1df_5.82.7601.18201_none_a4d3b9377117c3df` – Matze May 03 '15 at 02:01
  • Instead of `windres GUI.rc GUI.res`, try `windres GUI.rc GUI.o`. Also, specify the Window 95 controls as the minimum set of controls. – Cheers and hth. - Alf May 03 '15 at 04:09
  • Tried that one before, no effect... it also displays the old fashioned button, which was the reason i wanted to switch to the new styles... but no chance if the init doesn't work – Matze May 03 '15 at 11:13
  • 1
    Just FYI, `InitCommonControlsEx` is not responsible for intiialising visual styles. That's all down to the manifest. – Jonathan Potter May 03 '15 at 13:08
  • @JonathanPotter In fact it is, it ensures that the ComCtl32.dll is loaded and registers the common control classes. Afaik, the manifest gives metadata to the OS to ensure that only DLLs which are compatible are loaded, e.g. that only specific versions will be loaded. In this case Version 6.0 and newer – Matze May 03 '15 at 14:00
  • 1
    The documentation does not tell you to call `GetLastError`. It is a mistake to do so. – David Heffernan May 03 '15 at 14:08
  • @DavidHeffernan I've read somewhere about it but you're right... all in all it doesn't effect the result – Matze May 03 '15 at 14:56
  • 1
    I know. It's a general point. An incredibly common mistake. Always read the docs. – David Heffernan May 03 '15 at 14:59
  • But sometimes the doc is not enough... no word given about what causes InitCommonControlsEx to return false... – Matze May 03 '15 at 15:05
  • Sure. I'm just trying to teach you something. My guess is that your manifest is somehow defective. – David Heffernan May 03 '15 at 17:41
  • Appreciate it - Had the same thought, but i tried several different manifests copy&paste, from msdn and other sources (yes recompiled etc.) but it didn't affect the issue – Matze May 03 '15 at 17:48
  • Shot in the dark: is there a *different* GUI.exe.manifest in the same folder as GUI.exe? (The problem isn't the mismatch, it would be that the file system manifest takes precedence according to MSDN.) – andlabs May 03 '15 at 18:00
  • There is only one GUI.exe.manifest in the main folder, because of tests i compile it by hand and move the compiled resource by hand into the build chain – Matze May 03 '15 at 18:06

0 Answers0