diff --git a/Sources/SwiftWin32/Support/WinSDK+Extensions.swift b/Sources/SwiftWin32/Support/WinSDK+Extensions.swift index f5cc0ac4..9b81c782 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 9279dcec..7fe85d51 100644 --- a/Sources/SwiftWin32/Views and Controls/PickerView.swift +++ b/Sources/SwiftWin32/Views and Controls/PickerView.swift @@ -29,7 +29,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) @@ -42,8 +42,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) { @@ -121,8 +121,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)) @@ -137,10 +137,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 85ffeb5a..2e905f0e 100644 --- a/Sources/SwiftWin32/Views and Controls/Stepper.swift +++ b/Sources/SwiftWin32/Views and Controls/Stepper.swift @@ -58,7 +58,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() @@ -79,10 +79,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) } } @@ -141,7 +141,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 62cff00f..bfccbb62 100644 --- a/Sources/SwiftWin32/Views and Controls/Table Views/TableView.swift +++ b/Sources/SwiftWin32/Views and Controls/Table Views/TableView.swift @@ -29,8 +29,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 96e73d78..3e1f941b 100644 --- a/Sources/SwiftWin32/Views and Controls/TextView.swift +++ b/Sources/SwiftWin32/Views and Controls/TextView.swift @@ -46,7 +46,7 @@ public class TextView: View { 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) }