Files
__mahjong/components/other/windows/otherWindows.swift
T
2026-11-05 22:13:32 +03:00

36 lines
1.1 KiB
Swift

import WinSDK
func otherSetupWindowIcon(_ iconId: Int) {
// Only visit windows owned by this UI thread, never another application's window
EnumThreadWindows(GetCurrentThreadId(), { wnd, iconId in
let resource = UnsafePointer<WCHAR>(bitPattern: Int(iconId))
let module = GetModuleHandleW(nil)
// Small icon
if let small = LoadImageW(
module,
resource,
UINT(IMAGE_ICON),
GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON),
UINT(LR_SHARED)
) {
SendMessageW(wnd, UINT(WM_SETICON), WPARAM(ICON_SMALL), LPARAM(Int(bitPattern: small)))
}
// Large icon
if let large = LoadImageW(
module,
resource,
UINT(IMAGE_ICON),
GetSystemMetrics(SM_CXICON),
GetSystemMetrics(SM_CYICON),
UINT(LR_SHARED)
) {
SendMessageW(wnd, UINT(WM_SETICON), WPARAM(ICON_BIG), LPARAM(Int(bitPattern: large)))
}
return true
}, LPARAM(iconId))
}