/// <summary>
 /// The platform quit message loop.
 /// </summary>
 protected override void QuitMessageLoop()
 {
     NativeWindow.Exit();
 }
Beispiel #2
0
        /// <summary>
        /// The window proc.
        /// </summary>
        /// <param name="hwnd">
        /// The hwnd.
        /// </param>
        /// <param name="umsg">
        /// The umsg.
        /// </param>
        /// <param name="wParam">
        /// The w param.
        /// </param>
        /// <param name="lParam">
        /// The l param.
        /// </param>
        /// <returns>
        /// The <see cref="IntPtr"/>.
        /// </returns>
        private IntPtr WindowProc(IntPtr hwnd, uint umsg, IntPtr wParam, IntPtr lParam)
        {
            var msg = (WM)umsg;

            switch (msg)
            {
            case WM.HOTKEY:
            {
                if (wParam == (IntPtr)1)
                {
                    User32Methods.PostMessage(Handle, (uint)WM.CLOSE, IntPtr.Zero, IntPtr.Zero);
                    return(IntPtr.Zero);
                }
                break;
            }

            case WM.SYSKEYDOWN:
            {
                if (_hostConfig.HostPlacement.KioskMode && (wParam == (IntPtr)VirtualKey.F4))
                {
                    return(IntPtr.Zero);
                }
                break;
            }

            case WM.ACTIVATE:
            {
                if (_hostConfig.HostPlacement.Frameless)
                {
                    var frameSizeY   = User32Methods.GetSystemMetrics(SystemMetrics.SM_CYFRAME);
                    var frameSizeX   = User32Methods.GetSystemMetrics(SystemMetrics.SM_CXFRAME);
                    var frameMargins = new Margins(frameSizeX, frameSizeX, frameSizeY, frameSizeY);
                    DwmApiMethods.DwmExtendFrameIntoClientArea(Handle, ref frameMargins);
                    User32Methods.SetWindowPos(hwnd, IntPtr.Zero, 0, 0, 0, 0, WindowPositionFlags.SWP_NOZORDER | WindowPositionFlags.SWP_NOOWNERZORDER | WindowPositionFlags.SWP_NOMOVE | WindowPositionFlags.SWP_NOSIZE | WindowPositionFlags.SWP_FRAMECHANGED);
                }

                break;
            }

            case WM.CREATE:
            {
                NativeInstance = this;
                Handle         = hwnd;
                var size = GetClientSize();
                OnCreate(hwnd, size.Width, size.Height);
                break;
            }

            case WM.ERASEBKGND:
                return(new IntPtr(1));

            case WM.SIZE:
            {
                var size = GetClientSize();
                OnSize(size.Width, size.Height);
                break;
            }

            case WM.CLOSE:
            {
                OnExit();
                Exit();
                Environment.Exit(0);
                break;
            }

            case WM.NCHITTEST:
                if (_hostConfig.HostPlacement.Frameless)
                {
                    return((IntPtr)NativeMethods.HT_CAPTION);
                }
                break;
            }

            return(User32Methods.DefWindowProc(hwnd, umsg, wParam, lParam));
        }
 /// <summary>
 /// The platform run message loop.
 /// </summary>
 protected override void RunMessageLoop()
 {
     NativeWindow.RunMessageLoop();
 }