public virtual void Dispose() { lock (SyncRoot) { if (m_hWnd != IntPtr.Zero) { //GameDebugger.Log("Destroying window"); CloseEvent = null; MoveEvent = null; ResizeEvent = null; EnterSizeMoveEvent = null; ExitSizeMoveEvent = null; PreprocessWindowMessageEvent = null; PostprocessWindowMessageEvent = null; API.Externals.DestroyWindow(m_hWnd); Win32Application.UnregisterWindow(this); m_hWnd = IntPtr.Zero; //GameDebugger.Log("QuickAlgos window destroyed: 0x{0:x}", (int)m_hWnd); } } if (m_WindowClass != null) { m_WindowClass.Dispose(); m_WindowClass = null; } }
public Win32NativeWindow(WindowCreateStruct create_struct) { m_hWnd = IntPtr.Zero; m_WindowClass = null; WndClassInfo wc = new WndClassInfo { Style = create_struct.ClassStyle, ClassName = create_struct.ClassName, WndProc = Win32Application.WndProc, ClassExtra = create_struct.ClassExtra, WindowExtra = create_struct.WindowExtra, Instance = Win32Application.GetInstanceHandle(), Background = create_struct.Background, Icon = create_struct.Icon, Cursor = create_struct.Cursor, MenuName = create_struct.ClassMenu }; GameDebugger.EngineLog(LogLevel.Debug, "Registering window class '{0}'", wc.ClassName); m_WindowClass = new WindowClass(wc); if (!m_WindowClass.Registered) { throw new UserFriendlyException(String.Format("Failed to register window class '{0}'", wc.ClassName), "Error while trying to create a window"); } lock ( SyncRoot ) { if (create_struct.ParentWindow != null && create_struct.ParentWindow.Disposed) { throw new UserFriendlyException(String.Format("Child window '{0}' cannot be created since it's parent is already disposed", create_struct.WindowTitle), "Error while trying to create a window"); } GameDebugger.EngineLog(LogLevel.Debug, "Creating window {0}x{1} at {2},{3}", create_struct.Width, create_struct.Height, create_struct.X, create_struct.Y); unsafe { m_hWnd = API.Externals.CreateWindowEx( create_struct.ExStyle, wc.ClassName, create_struct.WindowTitle, create_struct.Style, create_struct.X, create_struct.Y, create_struct.Width, create_struct.Height, (create_struct.ParentWindow == null) ? IntPtr.Zero : create_struct.ParentWindow.Handle, create_struct.Menu, wc.Instance, create_struct.Param ); m_Width = create_struct.Width; m_Height = create_struct.Height; //GameDebugger.Log("QuickAlgos window created: 0x{0:x}", (int)m_hWnd); } } if (m_hWnd == IntPtr.Zero) { Dispose(); throw new UserFriendlyException(String.Format("Failed to create window '{0}'", create_struct.WindowTitle), "Error while trying to create a window"); } Win32Application.RegisterWindow(this); OnCreate(); }
static Win32Application() { Instance = new Win32Application(); }
public IApplication GetApplication() { return(Win32Application.GetInstance()); }