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

InitCommonControlsEx and its error messages #789

Open
felixf4xu opened this issue Nov 12, 2024 · 1 comment
Open

InitCommonControlsEx and its error messages #789

felixf4xu opened this issue Nov 12, 2024 · 1 comment

Comments

@felixf4xu
Copy link

Hi,

This is a follow-up issue of #645 (comment).

I played with the code a little bit:

  var ICCE: INITCOMMONCONTROLSEX =
      INITCOMMONCONTROLSEX(dwSize: DWORD(MemoryLayout<INITCOMMONCONTROLSEX>.size),
                           dwICC: dwICC)
  if !InitCommonControlsEx(&ICCE) {
    log.error("InitCommonControlsEx: \(Error(win32: GetLastError()))")
  }

I found 2 results:

  1. if mt tool is not called (no manifest file), InitCommonControlsEx will fail but GetLastError() is 0 (no error), in this case, there will be a very confusing log like this: error message of no errors:

error org.compnerd.swift-win32 : [SwiftWin32] InitCommonControlsEx: Win32 Error 0 - The operation completed successfully.

If mt tool is called, the error message is gone.

  1. Only ICC_STANDARD_CLASSES causes the issue 1) above, if ICC_STANDARD_CLASSES is not used at all, mt does not matter, InitCommonControlsEx will always succeed.

By its name, ICC_STANDARD_CLASSES seems to have effects on buttons at lease, but at least to "UICatalog" UI, all controls including buttons are initialized correctly without ICC_STANDARD_CLASSES.

So maybe we can remove ICC_STANDARD_CLASSES? It will make InitCommonControlsEx to always succeed (with or without mt)
and have no bad effect on the buttons and other controls.

@compnerd
Copy link
Owner

There are small UI differences IIRC between the two path. mt should be called on the binary, especially for modern Windows applications. The problem is that the SPM tooling doesn't have a good extension point to allow us to ensure that mt is run at the appropriate time. This is not a problem with CMake.

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

No branches or pull requests

2 participants