Skip to content

Commit c6755bc

Browse files
committed
WinSDK: add an overload for WS_CAPTION
`WS_CAPTION` falls into the same category as the other window style values - it is meant to be a DWORD. In C/C++, the type is implicitly converted, however, in Swift, it will not be. Provide a DWORD overload of the value. For the cases where we need the value as a `LONG`, we can explicitly use the `WinSDK.` prefix to retrieve the long typed value. This cleans up most of the usage of the value.
1 parent adf282c commit c6755bc

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Sources/SwiftWin32/Support/WinSDK+Extensions.swift

+5
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ internal var WS_BORDER: DWORD {
8181
DWORD(WinSDK.WS_BORDER)
8282
}
8383

84+
@_transparent
85+
internal var WS_CAPTION: DWORD {
86+
DWORD(WinSDK.WS_CAPTION)
87+
}
88+
8489
@_transparent
8590
internal var WS_HSCROLL: DWORD {
8691
DWORD(WinSDK.WS_HSCROLL)

Sources/SwiftWin32/Views and Controls/View.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ public class View: Responder {
379379
superview.willRemoveSubview(self)
380380

381381
// Update the Window style.
382-
self.GWL_STYLE &= ~LONG(bitPattern: WS_POPUP | DWORD(WS_CAPTION))
382+
self.GWL_STYLE &= ~LONG(bitPattern: WS_POPUP | WS_CAPTION)
383383
self.GWL_STYLE &= ~WS_CHILD
384384
// FIXME(compnerd) can this be avoided somehow?
385385
if self is TextField || self is TextView || self is TableView {
@@ -431,7 +431,7 @@ public class View: Responder {
431431
// `WM_UPDATEUISTATE`.
432432

433433
// Update the window style.
434-
view.GWL_STYLE &= ~LONG(bitPattern: WS_POPUP | DWORD(WS_CAPTION))
434+
view.GWL_STYLE &= ~LONG(bitPattern: WS_POPUP | WS_CAPTION)
435435
view.GWL_STYLE |= WS_CHILD
436436
// FIXME(compnerd) can this be avoided somehow?
437437
if view is TextField || view is TextView || view is TableView {

0 commit comments

Comments
 (0)