Skip to content

Commit 793977b

Browse files
committed
fix(win32): handle MapWindowPoints correctly
Closes #55
1 parent c29fcbe commit 793977b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

winio-ui-win32/src/ui/canvas.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use windows::Win32::{
1818
},
1919
};
2020
use windows_sys::Win32::{
21-
Foundation::{HWND, LPARAM, POINT},
21+
Foundation::{HWND, LPARAM, POINT, SetLastError},
2222
Graphics::Gdi::MapWindowPoints,
2323
System::SystemServices::SS_OWNERDRAW,
2424
UI::{
@@ -203,7 +203,12 @@ impl Canvas {
203203
} else {
204204
unsafe { GetParent(handle) }
205205
};
206-
syscall!(BOOL, MapWindowPoints(parent, handle, &mut p, 1)).unwrap();
206+
unsafe { SetLastError(0) };
207+
match syscall!(BOOL, MapWindowPoints(parent, handle, &mut p, 1)) {
208+
Ok(_) => {}
209+
Err(e) if e.raw_os_error() == Some(0) => {}
210+
Err(e) => panic!("{e:?}"),
211+
}
207212
let p = self.handle.point_d2l((p.x, p.y));
208213
let size = self.size();
209214
if p.x >= 0.0 && p.x <= size.width && p.y >= 0.0 && p.y <= size.height {

0 commit comments

Comments
 (0)