From de47861fe373e553beacf579652b18c77510f0cb Mon Sep 17 00:00:00 2001 From: Krzysztof Kondrak Date: Mon, 28 Dec 2015 16:50:51 +0100 Subject: [PATCH] Ignore the "Class already exists" error in multiple-window application --- src/windows.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/windows.rs b/src/windows.rs index 9444f89..0a4afca 100644 --- a/src/windows.rs +++ b/src/windows.rs @@ -249,8 +249,14 @@ impl Window { }; if user32::RegisterClassW(&class) == 0 { - println!("Unable to register class, error {}", kernel32::GetLastError() as u32); - return None; + let err_code = kernel32::GetLastError() as u32; + + // ignore the "Class already exists" error for multiple windows + if err_code != 1410 + { + println!("Unable to register class, error {}", kernel32::GetLastError() as u32); + return None; + } } let new_width = width * scale_factor as usize;