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