Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid reporting false error for common controls initialization #436

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

franko
Copy link

@franko franko commented Nov 5, 2018

On my system, using Windows 7 plus Mingw64 I need the fix otherwise the common controls initialization fails but the error code is actually zero.

@msink
Copy link
Contributor

msink commented Nov 5, 2018

did you add in manifest

<assemblyIdentity
            type="win32"
            name="Microsoft.Windows.Common-Controls"
            version="6.0.0.0"
            processorArchitecture="*"
            publicKeyToken="6595b64144ccf1df"
            language="*"
        />

@franko
Copy link
Author

franko commented Nov 6, 2018

Didn't know about that. I will try if I figure out how to use this manifest thing. I'am using Mingw64 with Meson build system.

@msink
Copy link
Contributor

msink commented Nov 6, 2018

sample.manifest:

<?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="CompanyName.ProductName.YourApplication"
    type="win32"
  />
  <description>Your application description here.</description>
  <dependency>
    <dependentAssembly>
        <assemblyIdentity
            type="win32"
            name="Microsoft.Windows.Common-Controls"
            version="6.0.0.0"
            processorArchitecture="*"
            publicKeyToken="6595b64144ccf1df"
            language="*"
        />
    </dependentAssembly>
  </dependency>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="asInvoker"/>
      </requestedPrivileges>
    </security>
  </trustInfo>
  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    <application>
      <!--The ID below indicates application support for Windows Vista -->
      <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
      <!--The ID below indicates application support for Windows 7 -->
      <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
      <!--The ID below indicates application support for Windows 8 -->
      <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
      <!--The ID below indicates application support for Windows 8.1 -->
      <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
      <!--The ID below indicates application support for Windows 10 -->
      <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
    </application>
  </compatibility>
</assembly>

sample.rc:

// this is a UTF-8 file
#pragma code_page(65001)

// this is the Common Controls 6 manifest
// 1 is the value of CREATEPROCESS_MANIFEST_RESOURCE_ID and 24 is the value of RT_MANIFEST
1 24 "samples.manifest"

then run:
windres sample.rc -O coff -o sample.res

and add sample.res to objects list.

windows.compile_resources() should work in meson.

@franko
Copy link
Author

franko commented Nov 6, 2018

Ok it works, thank you.

Using the sample manifest now I get a native Windows 7 looks and the errors goes away.

Still I am wondering weather something should be fixed anyway. The reason is that when you link without a manifest everything works fine except that you get the following, confusing, error:

error initializing libui: initializing Common Controls; code 0 (0x00000000) The operation completed successfully.

The initialization terminate prematurely but the error message is confusing because GetLastError returns 0 and indicate that the operation was successful.

With the fix I propose the application behave correctly even without a manifest which is more friendly to developers like me that may happen to link the executable without a manifest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants