compnerd / compnerd/swift-win32

InitCommonControlsEx and its error messages

Open
#789 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
1.2k
Forks
76
PR merge metrics
No merged PRs in 30d

Description

Hi,

This is a follow-up issue of https://github.com/compnerd/swift-win32/issues/645#issuecomment-879189840.

I played with the code a little bit:
```swift
var ICCE: INITCOMMONCONTROLSEX =
INITCOMMONCONTROLSEX(dwSize: DWORD(MemoryLayout.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.

2) 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.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the InitCommonControlsEx call and the ICC_STANDARD_CLASSES configuration, then reproduce the behavior with and without the mt tool or manifest. Compare the UICatalog controls, especially buttons, and verify the resulting error handling. Done means determining whether ICC_STANDARD_CLASSES can be removed without breaking control initialization.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
desktop, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.