Пример #1
0
        /// <summary>
        /// Tells Windows to inform our game whenever the window is resized.
        /// </summary>
        private static void SetupResizeHook()
        {
            // Setup hook for when the game window is moved, resized, changes shape...
            WindowEventDelegate += WindowEventDelegateImpl;
            WindowEventHooks.SetWinEventHook
            (
                WindowEventHooks.EVENT_OBJECT_LOCATIONCHANGE,       // Minimum event code to capture
                WindowEventHooks.EVENT_OBJECT_LOCATIONCHANGE,       // Maximum event code to capture
                IntPtr.Zero,                                        // DLL Handle (none required)
                WindowEventDelegate,                                // Pointer to the hook function. (Delegate in our case)
                0,                                                  // Process ID (0 = all)
                0,                                                  // Thread ID (0 = all)
                WindowEventHooks.WINEVENT_OUTOFCONTEXT              // Flags: Allow cross-process event hooking
            );

            _resizeHookSetup = true;
        }
        /// <summary>
        /// Sets up the overlay window properties such as window style, topmost status, etc.
        /// </summary>
        private void SetupWindow()
        {
            // Set the appropriate window styles.
            SetWindowStyles();

            // Adjust window size and properties to overlap the game window.
            AdjustOverlayToGameWindow();

            // Setup hook for when the game window is moved, resized, changes shape...
            WindowEventDelegate += WinEventProc;
            WindowEventHooks.SetWinEventHook
            (
                WindowEventHooks.EVENT_OBJECT_LOCATIONCHANGE,       // Minimum event code to capture
                WindowEventHooks.EVENT_OBJECT_LOCATIONCHANGE,       // Maximum event code to capture
                IntPtr.Zero,                                        // DLL Handle (none required)
                WindowEventDelegate,                                // Pointer to the hook function. (Delegate in our case)
                0,                                                  // Process ID (0 = all)
                0,                                                  // Thread ID (0 = all)
                WindowEventHooks.WINEVENT_OUTOFCONTEXT              // Flags: Allow cross-process event hooking
            );

            // Expand Aero Glass onto Client Area
            ExtendFrameToClientArea();
        }