authorgravatar for jens.goldberg@gmail.comAransentin <jens.goldberg@gmail.com> 2020-11-22 14:51:32+00:00
committergravatar for jens.goldberg@gmail.comAransentin <jens.goldberg@gmail.com> 2020-11-22 14:51:32+00:00
log6fd536a50c087f4297f87034ef8891fbd41aa356
treef35fe30d23a996deecb6840c6d43b72bfef33164
parentbbc2c7c268bae51c5cafc1c44f82eb056839ae1a

Fixed bugs, style suggestions


1 files changed, 69 insertions(+), 68 deletions(-)

lib/std/os/windows/user32.zig+69-68
...@@ -86,7 +86,8 @@ pub const WM_SYSKEYDOWN = 0x0104;...@@ -86,7 +86,8 @@ pub const WM_SYSKEYDOWN = 0x0104;
86pub const WM_SYSKEYUP = 0x0105;86pub const WM_SYSKEYUP = 0x0105;
87pub const WM_SYSCHAR = 0x0106;87pub const WM_SYSCHAR = 0x0106;
88pub const WM_SYSDEADCHAR = 0x0107;88pub const WM_SYSDEADCHAR = 0x0107;
89pub const WM_KEYLAST = 0x0108;89pub const WM_UNICHAR = 0x0109;
90pub const WM_KEYLAST = 0x0109;
90pub const WM_INITDIALOG = 0x0110;91pub const WM_INITDIALOG = 0x0110;
91pub const WM_COMMAND = 0x0111;92pub const WM_COMMAND = 0x0111;
92pub const WM_SYSCOMMAND = 0x0112;93pub const WM_SYSCOMMAND = 0x0112;
...@@ -128,11 +129,11 @@ pub fn getMessageA(lpMsg: *MSG, hWnd: ?HWND, wMsgFilterMin: u32, wMsgFilterMax:...@@ -128,11 +129,11 @@ pub fn getMessageA(lpMsg: *MSG, hWnd: ?HWND, wMsgFilterMin: u32, wMsgFilterMax:
128 const r = GetMessageA(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);129 const r = GetMessageA(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);
129 if (r == 0) return error.Quit;130 if (r == 0) return error.Quit;
130 if (r != -1) return;131 if (r != -1) return;
131 return switch (GetLastError()) {132 switch (GetLastError()) {
132 .INVALID_WINDOW_HANDLE => unreachable,133 .INVALID_WINDOW_HANDLE => unreachable,
133 .INVALID_PARAMETER => unreachable,134 .INVALID_PARAMETER => unreachable,
134 else => |err| return windows.unexpectedError(err),135 else => |err| return windows.unexpectedError(err),
135 };136 }
136}137}
137138
138pub extern "user32" fn GetMessageW(lpMsg: *MSG, hWnd: ?HWND, wMsgFilterMin: UINT, wMsgFilterMax: UINT) callconv(WINAPI) BOOL;139pub extern "user32" fn GetMessageW(lpMsg: *MSG, hWnd: ?HWND, wMsgFilterMin: UINT, wMsgFilterMax: UINT) callconv(WINAPI) BOOL;
...@@ -143,11 +144,11 @@ pub fn getMessageW(lpMsg: *MSG, hWnd: ?HWND, wMsgFilterMin: u32, wMsgFilterMax:...@@ -143,11 +144,11 @@ pub fn getMessageW(lpMsg: *MSG, hWnd: ?HWND, wMsgFilterMin: u32, wMsgFilterMax:
143 const r = function(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);144 const r = function(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);
144 if (r == 0) return error.Quit;145 if (r == 0) return error.Quit;
145 if (r != -1) return;146 if (r != -1) return;
146 return switch (GetLastError()) {147 switch (GetLastError()) {
147 .INVALID_WINDOW_HANDLE => unreachable,148 .INVALID_WINDOW_HANDLE => unreachable,
148 .INVALID_PARAMETER => unreachable,149 .INVALID_PARAMETER => unreachable,
149 else => |err| return windows.unexpectedError(err),150 else => |err| return windows.unexpectedError(err),
150 };151 }
151}152}
152153
153pub const PM_NOREMOVE = 0x0000;154pub const PM_NOREMOVE = 0x0000;
...@@ -159,11 +160,11 @@ pub fn peekMessageA(lpMsg: *MSG, hWnd: ?HWND, wMsgFilterMin: u32, wMsgFilterMax:...@@ -159,11 +160,11 @@ pub fn peekMessageA(lpMsg: *MSG, hWnd: ?HWND, wMsgFilterMin: u32, wMsgFilterMax:
159 const r = PeekMessageA(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg);160 const r = PeekMessageA(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg);
160 if (r == 0) return false;161 if (r == 0) return false;
161 if (r != -1) return true;162 if (r != -1) return true;
162 return switch (GetLastError()) {163 switch (GetLastError()) {
163 .INVALID_WINDOW_HANDLE => unreachable,164 .INVALID_WINDOW_HANDLE => unreachable,
164 .INVALID_PARAMETER => unreachable,165 .INVALID_PARAMETER => unreachable,
165 else => |err| return windows.unexpectedError(err),166 else => |err| return windows.unexpectedError(err),
166 };167 }
167}168}
168169
169pub extern "user32" fn PeekMessageW(lpMsg: *MSG, hWnd: ?HWND, wMsgFilterMin: UINT, wMsgFilterMax: UINT, wRemoveMsg: UINT) callconv(WINAPI) BOOL;170pub extern "user32" fn PeekMessageW(lpMsg: *MSG, hWnd: ?HWND, wMsgFilterMin: UINT, wMsgFilterMax: UINT, wRemoveMsg: UINT) callconv(WINAPI) BOOL;
...@@ -174,11 +175,11 @@ pub fn peekMessageW(lpMsg: *MSG, hWnd: ?HWND, wMsgFilterMin: u32, wMsgFilterMax:...@@ -174,11 +175,11 @@ pub fn peekMessageW(lpMsg: *MSG, hWnd: ?HWND, wMsgFilterMin: u32, wMsgFilterMax:
174 const r = function(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg);175 const r = function(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg);
175 if (r == 0) return false;176 if (r == 0) return false;
176 if (r != -1) return true;177 if (r != -1) return true;
177 return switch (GetLastError()) {178 switch (GetLastError()) {
178 .INVALID_WINDOW_HANDLE => unreachable,179 .INVALID_WINDOW_HANDLE => unreachable,
179 .INVALID_PARAMETER => unreachable,180 .INVALID_PARAMETER => unreachable,
180 else => |err| return windows.unexpectedError(err),181 else => |err| return windows.unexpectedError(err),
181 };182 }
182}183}
183184
184pub extern "user32" fn TranslateMessage(lpMsg: *const MSG) callconv(WINAPI) BOOL;185pub extern "user32" fn TranslateMessage(lpMsg: *const MSG) callconv(WINAPI) BOOL;
...@@ -263,46 +264,46 @@ pub extern "user32" fn RegisterClassExA(*const WNDCLASSEXA) callconv(WINAPI) ATO...@@ -263,46 +264,46 @@ pub extern "user32" fn RegisterClassExA(*const WNDCLASSEXA) callconv(WINAPI) ATO
263pub fn registerClassExA(window_class: *const WNDCLASSEXA) !ATOM {264pub fn registerClassExA(window_class: *const WNDCLASSEXA) !ATOM {
264 const atom = RegisterClassExA(window_class);265 const atom = RegisterClassExA(window_class);
265 if (atom != 0) return atom;266 if (atom != 0) return atom;
266 return switch (GetLastError()) {267 switch (GetLastError()) {
267 .CLASS_ALREADY_EXISTS => error.AlreadyExists,268 .CLASS_ALREADY_EXISTS => return error.AlreadyExists,
268 .INVALID_PARAMETER => unreachable,269 .INVALID_PARAMETER => unreachable,
269 else => |err| return windows.unexpectedError(err),270 else => |err| return windows.unexpectedError(err),
270 };271 }
271}272}
272273
273pub extern "user32" fn RegisterClassExW(*const WNDCLASSEXW) callconv(WINAPI) ATOM;274pub extern "user32" fn RegisterClassExW(*const WNDCLASSEXW) callconv(WINAPI) ATOM;
274pub var pfnRegisterClassExW: @TypeOf(RegisterClassExW) = undefined;275pub var pfnRegisterClassExW: @TypeOf(RegisterClassExW) = undefined;
275pub fn registerClassExW(window_class: *const WNDCLASSEXA) !ATOM {276pub fn registerClassExW(window_class: *const WNDCLASSEXW) !ATOM {
276 const function = selectSymbol(RegisterClassExW, pfnRegisterClassExW, .win2k);277 const function = selectSymbol(RegisterClassExW, pfnRegisterClassExW, .win2k);
277 const atom = function(window_class);278 const atom = function(window_class);
278 if (atom != 0) return atom;279 if (atom != 0) return atom;
279 return switch (GetLastError()) {280 switch (GetLastError()) {
280 .CLASS_ALREADY_EXISTS => error.AlreadyExists,281 .CLASS_ALREADY_EXISTS => return error.AlreadyExists,
281 .CALL_NOT_IMPLEMENTED => unreachable,282 .CALL_NOT_IMPLEMENTED => unreachable,
282 .INVALID_PARAMETER => unreachable,283 .INVALID_PARAMETER => unreachable,
283 else => |err| return windows.unexpectedError(err),284 else => |err| return windows.unexpectedError(err),
284 };285 }
285}286}
286287
287pub extern "user32" fn UnregisterClassA(lpClassName: LPCSTR, hInstance: HINSTANCE) callconv(.Stdcall) BOOL;288pub extern "user32" fn UnregisterClassA(lpClassName: [*:0]const u8, hInstance: HINSTANCE) callconv(WINAPI) BOOL;
288pub fn unregisterClassA(lpClassName: [*:0]const u8, hInstance: HINSTANCE) !void {289pub fn unregisterClassA(lpClassName: [*:0]const u8, hInstance: HINSTANCE) !void {
289 if (UnregisterClassA(lpClassName, hInstance) == 0) {290 if (UnregisterClassA(lpClassName, hInstance) == 0) {
290 return switch (GetLastError()) {291 switch (GetLastError()) {
291 .CLASS_DOES_NOT_EXIST => error.ClassDoesNotExist,292 .CLASS_DOES_NOT_EXIST => return error.ClassDoesNotExist,
292 else => |err| return windows.unexpectedError(err),293 else => |err| return windows.unexpectedError(err),
293 };294 }
294 }295 }
295}296}
296297
297pub extern "user32" fn UnregisterClassW(lpClassName: LPCWSTR, hInstance: HINSTANCE) callconv(.Stdcall) BOOL;298pub extern "user32" fn UnregisterClassW(lpClassName: [*:0]const u16, hInstance: HINSTANCE) callconv(.Stdcall) BOOL;
298pub var pfnUnregisterClassW: @TypeOf(UnregisterClassW) = undefined;299pub var pfnUnregisterClassW: @TypeOf(UnregisterClassW) = undefined;
299pub fn unregisterClassW(lpClassName: [*:0]const u16, hInstance: HINSTANCE) !void {300pub fn unregisterClassW(lpClassName: [*:0]const u16, hInstance: HINSTANCE) !void {
300 const function = selectSymbol(UnregisterClassW, pfnUnregisterClassW, .win2k);301 const function = selectSymbol(UnregisterClassW, pfnUnregisterClassW, .win2k);
301 if (function(lpClassName, hInstance) == 0) {302 if (function(lpClassName, hInstance) == 0) {
302 return switch (GetLastError()) {303 switch (GetLastError()) {
303 .CLASS_DOES_NOT_EXIST => error.ClassDoesNotExist,304 .CLASS_DOES_NOT_EXIST => return error.ClassDoesNotExist,
304 else => |err| return windows.unexpectedError(err),305 else => |err| return windows.unexpectedError(err),
305 };306 }
306 }307 }
307}308}
308309
...@@ -354,8 +355,8 @@ pub const WS_EX_CONTROLPARENT = 0x00010000;...@@ -354,8 +355,8 @@ pub const WS_EX_CONTROLPARENT = 0x00010000;
354pub const WS_EX_STATICEDGE = 0x00020000;355pub const WS_EX_STATICEDGE = 0x00020000;
355pub const WS_EX_APPWINDOW = 0x00040000;356pub const WS_EX_APPWINDOW = 0x00040000;
356pub const WS_EX_LAYERED = 0x00080000;357pub const WS_EX_LAYERED = 0x00080000;
357pub const WS_EX_OVERLAPPEDWINDOW = (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE);358pub const WS_EX_OVERLAPPEDWINDOW = WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE;
358pub const WS_EX_PALETTEWINDOW = (WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST);359pub const WS_EX_PALETTEWINDOW = WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST;
359360
360pub const CW_USEDEFAULT = @bitCast(i32, @as(u32, 0x80000000));361pub const CW_USEDEFAULT = @bitCast(i32, @as(u32, 0x80000000));
361362
...@@ -364,11 +365,11 @@ pub fn createWindowExA(dwExStyle: u32, lpClassName: [*:0]const u8, lpWindowName:...@@ -364,11 +365,11 @@ pub fn createWindowExA(dwExStyle: u32, lpClassName: [*:0]const u8, lpWindowName:
364 const window = CreateWindowExA(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWindParent, hMenu, hInstance, lpParam);365 const window = CreateWindowExA(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWindParent, hMenu, hInstance, lpParam);
365 if (window) |win| return win;366 if (window) |win| return win;
366367
367 return switch (GetLastError()) {368 switch (GetLastError()) {
368 .CLASS_DOES_NOT_EXIST => error.ClassDoesNotExist,369 .CLASS_DOES_NOT_EXIST => return error.ClassDoesNotExist,
369 .INVALID_PARAMETER => unreachable,370 .INVALID_PARAMETER => unreachable,
370 else => |err| return windows.unexpectedError(err),371 else => |err| return windows.unexpectedError(err),
371 };372 }
372}373}
373374
374pub extern "user32" fn CreateWindowExW(dwExStyle: DWORD, lpClassName: [*:0]const u16, lpWindowName: [*:0]const u16, dwStyle: DWORD, X: i32, Y: i32, nWidth: i32, nHeight: i32, hWindParent: ?HWND, hMenu: ?HMENU, hInstance: HINSTANCE, lpParam: ?LPVOID) callconv(WINAPI) ?HWND;375pub extern "user32" fn CreateWindowExW(dwExStyle: DWORD, lpClassName: [*:0]const u16, lpWindowName: [*:0]const u16, dwStyle: DWORD, X: i32, Y: i32, nWidth: i32, nHeight: i32, hWindParent: ?HWND, hMenu: ?HMENU, hInstance: HINSTANCE, lpParam: ?LPVOID) callconv(WINAPI) ?HWND;
...@@ -378,21 +379,21 @@ pub fn createWindowExW(dwExStyle: u32, lpClassName: [*:0]const u16, lpWindowName...@@ -378,21 +379,21 @@ pub fn createWindowExW(dwExStyle: u32, lpClassName: [*:0]const u16, lpWindowName
378 const window = function(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWindParent, hMenu, hInstance, lpParam);379 const window = function(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWindParent, hMenu, hInstance, lpParam);
379 if (window) |win| return win;380 if (window) |win| return win;
380381
381 return switch (GetLastError()) {382 switch (GetLastError()) {
382 .CLASS_DOES_NOT_EXIST => error.ClassDoesNotExist,383 .CLASS_DOES_NOT_EXIST => return error.ClassDoesNotExist,
383 .INVALID_PARAMETER => unreachable,384 .INVALID_PARAMETER => unreachable,
384 else => |err| return windows.unexpectedError(err),385 else => |err| return windows.unexpectedError(err),
385 };386 }
386}387}
387388
388pub extern "user32" fn DestroyWindow(hWnd: HWND) callconv(WINAPI) BOOL;389pub extern "user32" fn DestroyWindow(hWnd: HWND) callconv(WINAPI) BOOL;
389pub fn destroyWindow(hWnd: HWND) !void {390pub fn destroyWindow(hWnd: HWND) !void {
390 if (DestroyWindow(hWnd) == 0) {391 if (DestroyWindow(hWnd) == 0) {
391 return switch (GetLastError()) {392 switch (GetLastError()) {
392 .INVALID_WINDOW_HANDLE => unreachable,393 .INVALID_WINDOW_HANDLE => unreachable,
393 .INVALID_PARAMETER => unreachable,394 .INVALID_PARAMETER => unreachable,
394 else => |err| return windows.unexpectedError(err),395 else => |err| return windows.unexpectedError(err),
395 };396 }
396 }397 }
397}398}
398399
...@@ -420,11 +421,11 @@ pub fn showWindow(hWnd: HWND, nCmdShow: i32) bool {...@@ -420,11 +421,11 @@ pub fn showWindow(hWnd: HWND, nCmdShow: i32) bool {
420pub extern "user32" fn UpdateWindow(hWnd: HWND) callconv(WINAPI) BOOL;421pub extern "user32" fn UpdateWindow(hWnd: HWND) callconv(WINAPI) BOOL;
421pub fn updateWindow(hWnd: HWND) !void {422pub fn updateWindow(hWnd: HWND) !void {
422 if (ShowWindow(hWnd, nCmdShow) == 0) {423 if (ShowWindow(hWnd, nCmdShow) == 0) {
423 return switch (GetLastError()) {424 switch (GetLastError()) {
424 .INVALID_WINDOW_HANDLE => unreachable,425 .INVALID_WINDOW_HANDLE => unreachable,
425 .INVALID_PARAMETER => unreachable,426 .INVALID_PARAMETER => unreachable,
426 else => |err| return windows.unexpectedError(err),427 else => |err| return windows.unexpectedError(err),
427 };428 }
428 }429 }
429}430}
430431
...@@ -433,10 +434,10 @@ pub fn adjustWindowRectEx(lpRect: *RECT, dwStyle: u32, bMenu: bool, dwExStyle: u...@@ -433,10 +434,10 @@ pub fn adjustWindowRectEx(lpRect: *RECT, dwStyle: u32, bMenu: bool, dwExStyle: u
433 assert(dwStyle & WS_OVERLAPPED == 0);434 assert(dwStyle & WS_OVERLAPPED == 0);
434435
435 if (AdjustWindowRectEx(lpRect, dwStyle, bMenu, dwExStyle) == 0) {436 if (AdjustWindowRectEx(lpRect, dwStyle, bMenu, dwExStyle) == 0) {
436 return switch (GetLastError()) {437 switch (GetLastError()) {
437 .INVALID_PARAMETER => unreachable,438 .INVALID_PARAMETER => unreachable,
438 else => |err| return windows.unexpectedError(err),439 else => |err| return windows.unexpectedError(err),
439 };440 }
440 }441 }
441}442}
442443
...@@ -453,12 +454,12 @@ pub fn getWindowLongA(hWnd: HWND, nIndex: i32) !i32 {...@@ -453,12 +454,12 @@ pub fn getWindowLongA(hWnd: HWND, nIndex: i32) !i32 {
453 const value = GetWindowLongA(hWnd, nIndex);454 const value = GetWindowLongA(hWnd, nIndex);
454 if (value != 0) return value;455 if (value != 0) return value;
455456
456 return switch (GetLastError()) {457 switch (GetLastError()) {
457 .SUCCESS => 0,458 .SUCCESS => return 0,
458 .INVALID_WINDOW_HANDLE => unreachable,459 .INVALID_WINDOW_HANDLE => unreachable,
459 .INVALID_PARAMETER => unreachable,460 .INVALID_PARAMETER => unreachable,
460 else => |err| return windows.unexpectedError(err),461 else => |err| return windows.unexpectedError(err),
461 };462 }
462}463}
463464
464pub extern "user32" fn GetWindowLongW(hWnd: HWND, nIndex: i32) callconv(WINAPI) LONG;465pub extern "user32" fn GetWindowLongW(hWnd: HWND, nIndex: i32) callconv(WINAPI) LONG;
...@@ -469,12 +470,12 @@ pub fn getWindowLongW(hWnd: HWND, nIndex: i32) !i32 {...@@ -469,12 +470,12 @@ pub fn getWindowLongW(hWnd: HWND, nIndex: i32) !i32 {
469 const value = function(hWnd, nIndex);470 const value = function(hWnd, nIndex);
470 if (value != 0) return value;471 if (value != 0) return value;
471472
472 return switch (GetLastError()) {473 switch (GetLastError()) {
473 .SUCCESS => 0,474 .SUCCESS => return 0,
474 .INVALID_WINDOW_HANDLE => unreachable,475 .INVALID_WINDOW_HANDLE => unreachable,
475 .INVALID_PARAMETER => unreachable,476 .INVALID_PARAMETER => unreachable,
476 else => |err| return windows.unexpectedError(err),477 else => |err| return windows.unexpectedError(err),
477 };478 }
478}479}
479480
480pub extern "user32" fn GetWindowLongPtrA(hWnd: HWND, nIndex: i32) callconv(WINAPI) LONG_PTR;481pub extern "user32" fn GetWindowLongPtrA(hWnd: HWND, nIndex: i32) callconv(WINAPI) LONG_PTR;
...@@ -486,12 +487,12 @@ pub fn getWindowLongPtrA(hWnd: HWND, nIndex: i32) !isize {...@@ -486,12 +487,12 @@ pub fn getWindowLongPtrA(hWnd: HWND, nIndex: i32) !isize {
486 const value = GetWindowLongPtrA(hWnd, nIndex);487 const value = GetWindowLongPtrA(hWnd, nIndex);
487 if (value != 0) return value;488 if (value != 0) return value;
488489
489 return switch (GetLastError()) {490 switch (GetLastError()) {
490 .SUCCESS => 0,491 .SUCCESS => return 0,
491 .INVALID_WINDOW_HANDLE => unreachable,492 .INVALID_WINDOW_HANDLE => unreachable,
492 .INVALID_PARAMETER => unreachable,493 .INVALID_PARAMETER => unreachable,
493 else => |err| return windows.unexpectedError(err),494 else => |err| return windows.unexpectedError(err),
494 };495 }
495}496}
496497
497pub extern "user32" fn GetWindowLongPtrW(hWnd: HWND, nIndex: i32) callconv(WINAPI) LONG_PTR;498pub extern "user32" fn GetWindowLongPtrW(hWnd: HWND, nIndex: i32) callconv(WINAPI) LONG_PTR;
...@@ -503,12 +504,12 @@ pub fn getWindowLongPtrW(hWnd: HWND, nIndex: i32) !isize {...@@ -503,12 +504,12 @@ pub fn getWindowLongPtrW(hWnd: HWND, nIndex: i32) !isize {
503 const value = function(hWnd, nIndex);504 const value = function(hWnd, nIndex);
504 if (value != 0) return value;505 if (value != 0) return value;
505506
506 return switch (GetLastError()) {507 switch (GetLastError()) {
507 .SUCCESS => 0,508 .SUCCESS => return 0,
508 .INVALID_WINDOW_HANDLE => unreachable,509 .INVALID_WINDOW_HANDLE => unreachable,
509 .INVALID_PARAMETER => unreachable,510 .INVALID_PARAMETER => unreachable,
510 else => |err| return windows.unexpectedError(err),511 else => |err| return windows.unexpectedError(err),
511 };512 }
512}513}
513514
514pub extern "user32" fn SetWindowLongA(hWnd: HWND, nIndex: i32, dwNewLong: LONG) callconv(WINAPI) LONG;515pub extern "user32" fn SetWindowLongA(hWnd: HWND, nIndex: i32, dwNewLong: LONG) callconv(WINAPI) LONG;
...@@ -520,12 +521,12 @@ pub fn setWindowLongA(hWnd: HWND, nIndex: i32, dwNewLong: i32) !i32 {...@@ -520,12 +521,12 @@ pub fn setWindowLongA(hWnd: HWND, nIndex: i32, dwNewLong: i32) !i32 {
520 const value = SetWindowLongA(hWnd, nIndex, dwNewLong);521 const value = SetWindowLongA(hWnd, nIndex, dwNewLong);
521 if (value != 0) return value;522 if (value != 0) return value;
522523
523 return switch (GetLastError()) {524 switch (GetLastError()) {
524 .SUCCESS => 0,525 .SUCCESS => return 0,
525 .INVALID_WINDOW_HANDLE => unreachable,526 .INVALID_WINDOW_HANDLE => unreachable,
526 .INVALID_PARAMETER => unreachable,527 .INVALID_PARAMETER => unreachable,
527 else => |err| return windows.unexpectedError(err),528 else => |err| return windows.unexpectedError(err),
528 };529 }
529}530}
530531
531pub extern "user32" fn SetWindowLongW(hWnd: HWND, nIndex: i32, dwNewLong: LONG) callconv(WINAPI) LONG;532pub extern "user32" fn SetWindowLongW(hWnd: HWND, nIndex: i32, dwNewLong: LONG) callconv(WINAPI) LONG;
...@@ -537,12 +538,12 @@ pub fn setWindowLongW(hWnd: HWND, nIndex: i32, dwNewLong: i32) !i32 {...@@ -537,12 +538,12 @@ pub fn setWindowLongW(hWnd: HWND, nIndex: i32, dwNewLong: i32) !i32 {
537 const value = function(hWnd, nIndex, dwNewLong);538 const value = function(hWnd, nIndex, dwNewLong);
538 if (value != 0) return value;539 if (value != 0) return value;
539540
540 return switch (GetLastError()) {541 switch (GetLastError()) {
541 .SUCCESS => 0,542 .SUCCESS => return 0,
542 .INVALID_WINDOW_HANDLE => unreachable,543 .INVALID_WINDOW_HANDLE => unreachable,
543 .INVALID_PARAMETER => unreachable,544 .INVALID_PARAMETER => unreachable,
544 else => |err| return windows.unexpectedError(err),545 else => |err| return windows.unexpectedError(err),
545 };546 }
546}547}
547548
548pub extern "user32" fn SetWindowLongPtrA(hWnd: HWND, nIndex: i32, dwNewLong: LONG_PTR) callconv(WINAPI) LONG_PTR;549pub extern "user32" fn SetWindowLongPtrA(hWnd: HWND, nIndex: i32, dwNewLong: LONG_PTR) callconv(WINAPI) LONG_PTR;
...@@ -555,12 +556,12 @@ pub fn setWindowLongPtrA(hWnd: HWND, nIndex: i32, dwNewLong: isize) !isize {...@@ -555,12 +556,12 @@ pub fn setWindowLongPtrA(hWnd: HWND, nIndex: i32, dwNewLong: isize) !isize {
555 const value = SetWindowLongPtrA(hWnd, nIndex, dwNewLong);556 const value = SetWindowLongPtrA(hWnd, nIndex, dwNewLong);
556 if (value != 0) return value;557 if (value != 0) return value;
557558
558 return switch (GetLastError()) {559 switch (GetLastError()) {
559 .SUCCESS => 0,560 .SUCCESS => return 0,
560 .INVALID_WINDOW_HANDLE => unreachable,561 .INVALID_WINDOW_HANDLE => unreachable,
561 .INVALID_PARAMETER => unreachable,562 .INVALID_PARAMETER => unreachable,
562 else => |err| return windows.unexpectedError(err),563 else => |err| return windows.unexpectedError(err),
563 };564 }
564}565}
565566
566pub extern "user32" fn SetWindowLongPtrW(hWnd: HWND, nIndex: i32, dwNewLong: LONG_PTR) callconv(WINAPI) LONG_PTR;567pub extern "user32" fn SetWindowLongPtrW(hWnd: HWND, nIndex: i32, dwNewLong: LONG_PTR) callconv(WINAPI) LONG_PTR;
...@@ -573,12 +574,12 @@ pub fn setWindowLongPtrW(hWnd: HWND, nIndex: i32, dwNewLong: isize) !isize {...@@ -573,12 +574,12 @@ pub fn setWindowLongPtrW(hWnd: HWND, nIndex: i32, dwNewLong: isize) !isize {
573 const value = function(hWnd, nIndex, dwNewLong);574 const value = function(hWnd, nIndex, dwNewLong);
574 if (value != 0) return value;575 if (value != 0) return value;
575576
576 return switch (GetLastError()) {577 switch (GetLastError()) {
577 .SUCCESS => 0,578 .SUCCESS => return 0,
578 .INVALID_WINDOW_HANDLE => unreachable,579 .INVALID_WINDOW_HANDLE => unreachable,
579 .INVALID_PARAMETER => unreachable,580 .INVALID_PARAMETER => unreachable,
580 else => |err| return windows.unexpectedError(err),581 else => |err| return windows.unexpectedError(err),
581 };582 }
582}583}
583584
584pub extern "user32" fn GetDC(hWnd: ?HWND) callconv(WINAPI) ?HDC;585pub extern "user32" fn GetDC(hWnd: ?HWND) callconv(WINAPI) ?HDC;
...@@ -586,11 +587,11 @@ pub fn getDC(hWnd: ?HWND) !HDC {...@@ -586,11 +587,11 @@ pub fn getDC(hWnd: ?HWND) !HDC {
586 const hdc = GetDC(hWnd);587 const hdc = GetDC(hWnd);
587 if (hdc) |h| return h;588 if (hdc) |h| return h;
588589
589 return switch (GetLastError()) {590 switch (GetLastError()) {
590 .INVALID_WINDOW_HANDLE => unreachable,591 .INVALID_WINDOW_HANDLE => unreachable,
591 .INVALID_PARAMETER => unreachable,592 .INVALID_PARAMETER => unreachable,
592 else => |err| return windows.unexpectedError(err),593 else => |err| return windows.unexpectedError(err),
593 };594 }
594}595}
595596
596pub extern "user32" fn ReleaseDC(hWnd: ?HWND, hDC: HDC) callconv(WINAPI) i32;597pub extern "user32" fn ReleaseDC(hWnd: ?HWND, hDC: HDC) callconv(WINAPI) i32;
...@@ -652,11 +653,11 @@ pub extern "user32" fn MessageBoxA(hWnd: ?HWND, lpText: [*:0]const u8, lpCaption...@@ -652,11 +653,11 @@ pub extern "user32" fn MessageBoxA(hWnd: ?HWND, lpText: [*:0]const u8, lpCaption
652pub fn messageBoxA(hWnd: ?HWND, lpText: [*:0]const u8, lpCaption: [*:0]const u8, uType: u32) !i32 {653pub fn messageBoxA(hWnd: ?HWND, lpText: [*:0]const u8, lpCaption: [*:0]const u8, uType: u32) !i32 {
653 const value = MessageBoxA(hWnd, lpText, lpCaption, uType);654 const value = MessageBoxA(hWnd, lpText, lpCaption, uType);
654 if (value != 0) return value;655 if (value != 0) return value;
655 return switch (GetLastError()) {656 switch (GetLastError()) {
656 .INVALID_WINDOW_HANDLE => unreachable,657 .INVALID_WINDOW_HANDLE => unreachable,
657 .INVALID_PARAMETER => unreachable,658 .INVALID_PARAMETER => unreachable,
658 else => |err| return windows.unexpectedError(err),659 else => |err| return windows.unexpectedError(err),
659 };660 }
660}661}
661662
662pub extern "user32" fn MessageBoxW(hWnd: ?HWND, lpText: [*:0]const u16, lpCaption: ?[*:0]const u16, uType: UINT) callconv(WINAPI) i32;663pub extern "user32" fn MessageBoxW(hWnd: ?HWND, lpText: [*:0]const u16, lpCaption: ?[*:0]const u16, uType: UINT) callconv(WINAPI) i32;
...@@ -665,9 +666,9 @@ pub fn messageBoxW(hWnd: ?HWND, lpText: [*:0]const u16, lpCaption: [*:0]const u1...@@ -665,9 +666,9 @@ pub fn messageBoxW(hWnd: ?HWND, lpText: [*:0]const u16, lpCaption: [*:0]const u1
665 const function = selectSymbol(pfnMessageBoxW, MessageBoxW, .win2k);666 const function = selectSymbol(pfnMessageBoxW, MessageBoxW, .win2k);
666 const value = function(hWnd, lpText, lpCaption, uType);667 const value = function(hWnd, lpText, lpCaption, uType);
667 if (value != 0) return value;668 if (value != 0) return value;
668 return switch (GetLastError()) {669 switch (GetLastError()) {
669 .INVALID_WINDOW_HANDLE => unreachable,670 .INVALID_WINDOW_HANDLE => unreachable,
670 .INVALID_PARAMETER => unreachable,671 .INVALID_PARAMETER => unreachable,
671 else => |err| return windows.unexpectedError(err),672 else => |err| return windows.unexpectedError(err),
672 };673 }
673}674}