diff --git a/Sources/SwiftWin32/App and Environment/ApplicationMain.swift b/Sources/SwiftWin32/App and Environment/ApplicationMain.swift index a63c6869..793b2bfe 100644 --- a/Sources/SwiftWin32/App and Environment/ApplicationMain.swift +++ b/Sources/SwiftWin32/App and Environment/ApplicationMain.swift @@ -216,8 +216,8 @@ public func ApplicationMain(_ argc: Int32, // to execute, we wait until a new message is placed in the thread's message // queue or the timer must fire, otherwise we proceed to the next iteration // of mainLoop, using 0 as the wait timeout. - _ = WaitMessage(DWORD(exactly: limitDate?.timeIntervalSinceNow ?? 0 * 1000) - ?? DWORD.max) + _ = WaitMessage(UINT(exactly: limitDate?.timeIntervalSinceNow ?? 0 * 1000) + ?? UINT.max) } Application.shared.delegate?.applicationWillTerminate(Application.shared) diff --git a/Sources/SwiftWin32/Support/WinSDK+Extensions.swift b/Sources/SwiftWin32/Support/WinSDK+Extensions.swift index e87d7ec3..4ee3def9 100644 --- a/Sources/SwiftWin32/Support/WinSDK+Extensions.swift +++ b/Sources/SwiftWin32/Support/WinSDK+Extensions.swift @@ -3,6 +3,18 @@ import WinSDK +#if arch(i386) || arch(arm) +@_transparent +internal func GetWindowLongPtrW(_ hWnd: HWND, _ nIndex: CInt) -> LONG { + return GetWindowLongW(hWnd, nIndex) +} + +@_transparent +internal func SetWindowLongPtrW(_ hWnd: HWND, _ nIndex: CInt, _ dwNewLong: LONG) -> LONG { + return SetWindowLongW(hWnd, nIndex, dwNewLong) +} +#endif + internal let IDC_ARROW: UnsafePointer = UnsafePointer(bitPattern: 32512)! @@ -11,52 +23,52 @@ internal let IDC_ARROW: UnsafePointer = // winreg.h @_transparent internal var HKEY_CLASSES_ROOT: HKEY? { - HKEY(bitPattern: 0x80000000) + HKEY(bitPattern: UInt(0x80000000)) } @_transparent internal var HKEY_CURRENT_USER: HKEY? { - HKEY(bitPattern: 0x80000001) + HKEY(bitPattern: UInt(0x80000001)) } @_transparent internal var HKEY_LOCAL_MACHINE: HKEY? { - HKEY(bitPattern: 0x80000002) + HKEY(bitPattern: UInt(0x80000002)) } @_transparent internal var HKEY_USERS: HKEY? { - HKEY(bitPattern: 0x80000003) + HKEY(bitPattern: UInt(0x80000003)) } @_transparent internal var HKEY_PERFORMANCE_DATA: HKEY? { - HKEY(bitPattern: 0x80000004) + HKEY(bitPattern: UInt(0x80000004)) } @_transparent internal var HKEY_PERFORMANCE_TEXT: HKEY? { - HKEY(bitPattern: 0x80000050) + HKEY(bitPattern: UInt(0x80000050)) } @_transparent internal var HKEY_PERFORMANCE_NLSTEXT: HKEY? { - HKEY(bitPattern: 0x80000060) + HKEY(bitPattern: UInt(0x80000060)) } @_transparent internal var HKEY_CURRENT_CONFIG: HKEY? { - HKEY(bitPattern: 0x80000005) + HKEY(bitPattern: UInt(0x80000005)) } @_transparent internal var HKEY_DYN_DATA: HKEY? { - HKEY(bitPattern: 0x80000006) + HKEY(bitPattern: UInt(0x80000006)) } @_transparent internal var HKEY_CURRENT_USER_LOCAL_SETTINGS: HKEY? { - HKEY(bitPattern: 0x80000007) + HKEY(bitPattern: UInt(0x80000007)) } #endif diff --git a/Sources/SwiftWin32/Text Display and Fonts/Font.swift b/Sources/SwiftWin32/Text Display and Fonts/Font.swift index 3b505eaa..c661a79a 100644 --- a/Sources/SwiftWin32/Text Display and Fonts/Font.swift +++ b/Sources/SwiftWin32/Text Display and Fonts/Font.swift @@ -231,7 +231,7 @@ public class Font { log.error("GetObjectW: \(Error(win32: GetLastError()))") return self } - lfFont.lfHeight = PointToLogical(fontSize) + lfFont.lfHeight = LONG(PointToLogical(fontSize)) return Font(owning: CreateFontIndirectW(&lfFont)) } @@ -407,7 +407,7 @@ public class Font { return 0.0 } - return LogicalToPoint(lfFont.lfHeight) + return LogicalToPoint(Int32(lfFont.lfHeight)) } /// The top y-coordinate, offset from the baseline, of the font's longest diff --git a/Sources/SwiftWin32/Views and Controls/Control.swift b/Sources/SwiftWin32/Views and Controls/Control.swift index f893ab3e..c84ec786 100644 --- a/Sources/SwiftWin32/Views and Controls/Control.swift +++ b/Sources/SwiftWin32/Views and Controls/Control.swift @@ -262,27 +262,27 @@ extension Control.Event { /// All touch events. public static var allTouchEvents: Control.Event { - Control.Event(rawValue: 0x00000fff) + Control.Event(rawValue: RawValue(bitPattern: 0x00000fff)) } /// All editing touches for `TextField` objects. public static var allEditingEvents: Control.Event { - Control.Event(rawValue: 0x000f0000) + Control.Event(rawValue: RawValue(bitPattern: 0x000f0000)) } /// A range of control-event values available for application use. public static var applicationReserved: Control.Event { - Control.Event(rawValue: 0x0f000000) + Control.Event(rawValue: RawValue(bitPattern: 0x0f000000)) } /// A range of control-event values reserved for internal framework use. public static var systemReserved: Control.Event { - Control.Event(rawValue: 0xf0000000) + Control.Event(rawValue: RawValue(bitPattern: 0xf0000000)) } /// All events, including system events. public static var allEvents: Control.Event { - Control.Event(rawValue: 0xffffffff) + Control.Event(rawValue: RawValue(bitPattern: 0xffffffff)) } } diff --git a/Sources/SwiftWin32/Views and Controls/PickerView.swift b/Sources/SwiftWin32/Views and Controls/PickerView.swift index 8fc1e6ac..df5cf243 100644 --- a/Sources/SwiftWin32/Views and Controls/PickerView.swift +++ b/Sources/SwiftWin32/Views and Controls/PickerView.swift @@ -25,7 +25,7 @@ private let SwiftPickerViewProxyWindowProc: WNDPROC = { (hWnd, uMsg, wParam, lPa switch lpDrawItem.pointee.itemAction { case UINT(ODA_SELECT): _ = DrawFocusRect(lpDrawItem.pointee.hDC, &lpDrawItem.pointee.rcItem) - if lpDrawItem.pointee.itemState & DWORD(ODS_SELECTED) == DWORD(ODS_SELECTED) { + if DWORD(lpDrawItem.pointee.itemState) & DWORD(ODS_SELECTED) == DWORD(ODS_SELECTED) { // If the item is selected, we have drawn the focus rectangle and the // operation is complete. return LRESULT(1) @@ -38,8 +38,8 @@ private let SwiftPickerViewProxyWindowProc: WNDPROC = { (hWnd, uMsg, wParam, lPa if let view = unsafeBitCast(lpDrawItem.pointee.itemData, to: AnyObject.self) as? View { let rctRect: RECT = lpDrawItem.pointee.rcItem - _ = SetWindowPos(view.hWnd, nil, rctRect.left, rctRect.top, 0, 0, - UINT(SWP_NOSIZE)) + _ = SetWindowPos(view.hWnd, nil, CInt(rctRect.left), CInt(rctRect.top), + 0, 0, UINT(SWP_NOSIZE)) // Setting `isHidden` is necessary for Views generated after initial // call to `Window.makeKeyAndVisible()` if IsWindowVisible(GetParent(view.hWnd)) && !IsWindowVisible(view.hWnd) { @@ -117,8 +117,8 @@ private let SwiftPickerViewWindowProc: SUBCLASSPROC = { (hWnd, uMsg, wParam, lPa DeviceContextHandle(owning: GetDC(view.hWnd)) let hBitmap: BitmapHandle = BitmapHandle(owning: CreateCompatibleBitmap(hDCItem.value, - rcClient.right - rcClient.left, - rcClient.bottom - rcClient.top)) + CInt(rcClient.right - rcClient.left), + CInt(rcClient.bottom - rcClient.top))) let hDCMemory: DeviceContextHandle = DeviceContextHandle(owning: CreateCompatibleDC(nil)) @@ -133,10 +133,10 @@ private let SwiftPickerViewWindowProc: SUBCLASSPROC = { (hWnd, uMsg, wParam, lPa let hDC: DeviceContextHandle = DeviceContextHandle(owning: GetDC(hWnd)) - _ = BitBlt(hDC.value, cbiInfo.rcItem.left, cbiInfo.rcItem.top, - cbiInfo.rcItem.right - cbiInfo.rcItem.left, - cbiInfo.rcItem.bottom - cbiInfo.rcItem.top, hDCMemory.value, - 0, 0, UINT(SRCCOPY)) + _ = BitBlt(hDC.value, CInt(cbiInfo.rcItem.left), CInt(cbiInfo.rcItem.top), + CInt(cbiInfo.rcItem.right - cbiInfo.rcItem.left), + CInt(cbiInfo.rcItem.bottom - cbiInfo.rcItem.top), + hDCMemory.value, 0, 0, DWORD(SRCCOPY)) return lResult diff --git a/Sources/SwiftWin32/Views and Controls/Stepper.swift b/Sources/SwiftWin32/Views and Controls/Stepper.swift index 88d5b588..09e129cb 100644 --- a/Sources/SwiftWin32/Views and Controls/Stepper.swift +++ b/Sources/SwiftWin32/Views and Controls/Stepper.swift @@ -54,7 +54,7 @@ private class StepperProxy { public class Stepper: Control { private static let `class`: WindowClass = WindowClass(named: UPDOWN_CLASS) private static let style: WindowStyle = - (base: UInt32(UDS_HORZ) | WS_POPUP | WS_TABSTOP, extended: 0) + (base: DWORD(UDS_HORZ) | WS_POPUP | WS_TABSTOP, extended: 0) private static var proxy: StepperProxy = StepperProxy() @@ -75,10 +75,10 @@ public class Stepper: Control { /// A boolean value that determines whether the stepper can wrap its value to /// the minimum or maximum value when incrementing and decrementing the value. public var wraps: Bool { - get { self.GWL_STYLE & UDS_WRAP == UDS_WRAP } + get { self.GWL_STYLE & LONG(UDS_WRAP) == LONG(UDS_WRAP) } set { - self.GWL_STYLE = newValue ? self.GWL_STYLE | UDS_WRAP - : self.GWL_STYLE & ~UDS_WRAP + self.GWL_STYLE = newValue ? self.GWL_STYLE | LONG(UDS_WRAP) + : self.GWL_STYLE & ~LONG(UDS_WRAP) } } @@ -137,7 +137,7 @@ public class Stepper: Control { SendMessageW(self.hWnd, UINT(UDM_GETACCEL), WPARAM(1), LPARAM(UInt(bitPattern: $0))) } - value.nInc = DWORD(newValue) + value.nInc = UINT(newValue) _ = withUnsafeMutablePointer(to: &value) { SendMessageW(self.hWnd, UINT(UDM_SETACCEL), WPARAM(1), LPARAM(UInt(bitPattern: $0))) diff --git a/Sources/SwiftWin32/Views and Controls/Table Views/TableView.swift b/Sources/SwiftWin32/Views and Controls/Table Views/TableView.swift index 8a471c08..89f5ca99 100644 --- a/Sources/SwiftWin32/Views and Controls/Table Views/TableView.swift +++ b/Sources/SwiftWin32/Views and Controls/Table Views/TableView.swift @@ -25,8 +25,8 @@ private let SwiftTableViewProxyWindowProc: WNDPROC = { (hWnd, uMsg, wParam, lPar if let view = unsafeBitCast(lpDrawItem.pointee.itemData, to: AnyObject.self) as? View { let rctRect: RECT = lpDrawItem.pointee.rcItem - _ = SetWindowPos(view.hWnd, nil, rctRect.left, rctRect.top, 0, 0, - UINT(SWP_NOSIZE)) + _ = SetWindowPos(view.hWnd, nil, CInt(rctRect.left), CInt(rctRect.top), + 0, 0, UINT(SWP_NOSIZE)) // Setting `isHidden` is necessary for TableCells generated after // initial call to `Window.makeKeyAndVisible()` diff --git a/Sources/SwiftWin32/Views and Controls/TextView.swift b/Sources/SwiftWin32/Views and Controls/TextView.swift index 8cda12d3..e34b1e82 100644 --- a/Sources/SwiftWin32/Views and Controls/TextView.swift +++ b/Sources/SwiftWin32/Views and Controls/TextView.swift @@ -37,13 +37,13 @@ public class TextView: View { // Disable compatibility with the original Rich Edit and use the extended // text limit. _ = SendMessageW(self.hWnd, UINT(EM_EXLIMITTEXT), - WPARAM(0), LPARAM(bitPattern: UInt64(bitPattern: -1))) + WPARAM(0), LPARAM(UInt(bitPattern: -1))) } public func scrollRangeToVisible(_ range: NSRange) { SendMessageW(hWnd, UINT(EM_SETSEL), WPARAM(range.location), LPARAM(range.location + range.length)) - SendMessageW(hWnd, UINT(EM_SETSEL), UInt64(bitPattern: -1), -1) + SendMessageW(hWnd, UINT(EM_SETSEL), WPARAM(bitPattern: -1), -1) SendMessageW(hWnd, UINT(EM_SCROLLCARET), 0, 0) }