Fixed a bug if using WPF window as IWin32Window.