private bool CreateNativeWindow() { bool isCreated = false; uint windowStyle; uint windowStyleEx; Screen screen; Rectangle rectangle; windowStyle = (uint)WindowStyles.WS_POPUP | (uint)WindowStyles.WS_VISIBLE; windowStyleEx = (uint)WindowStylesEx.WS_EX_TOPMOST | (uint)WindowStylesEx.WS_EX_TOOLWINDOW; if (!this._transparencyKey.IsEmpty && this.IsLayeringSupported()) { windowStyleEx = (windowStyleEx | (uint)WindowStylesEx.WS_EX_LAYERED); // 524288 } screen = Screen.FromPoint(Control.MousePosition); rectangle = screen.WorkingArea; int posX = Math.Max(rectangle.X, (rectangle.X + ((rectangle.Width - this._width) / 2))); int posY = Math.Max(rectangle.Y, (rectangle.Y + ((rectangle.Height - this._height) / 2))); this._hwnd = APIWindow.CreateWindowEx(windowStyleEx, WindowClassName, "", (uint)windowStyle, posX, posY, this._width, this._height, IntPtr.Zero, IntPtr.Zero, APIDynamicLinkLibrary.GetModuleHandle(null), IntPtr.Zero); if (this._hwnd != IntPtr.Zero) { APIWindow.ShowWindow(this._hwnd, 1); APIWindow.UpdateWindow(this._hwnd); isCreated = true; } else { System.Console.WriteLine("Cannot create window. {0}", APIError.FormatMessage(APIError.GetLastError())); } return(isCreated); }