Ejemplo n.º 1
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Sets window styles by logical or'ing them in with the existing values. </summary>
        ///
        /// <param name="windowHandle"> Handle of the window. </param>
        /// <param name="index">        Zero-based index of the. </param>
        /// <param name="styles">       The styles. </param>
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        internal static void SetWindowStyles(IntPtr windowHandle, int index, WindowStyles styles)
        {
            var desiredStyle = new IntPtr(unchecked ((int)styles));
            var success      = IntPtr.Zero != PlatformSafe.SetWindow(windowHandle, index, desiredStyle);

            WriteLineIf(!success, LastWin32ErrorMessage);
        }
Ejemplo n.º 2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Clears the window styles. </summary>
        ///
        /// <param name="windowHandle"> Handle of the window. </param>
        /// <param name="index">        Zero-based index of the. </param>
        /// <param name="styles">       The styles. </param>
        ///
        /// <returns>   True if it succeeds, false if it fails. </returns>
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        internal static bool ClearWindowStyles(IntPtr windowHandle, int index, WindowStyles styles)
        {
            var desiredStyle = PlatformSafe.GetWindow(windowHandle, index);

            WriteLineIf(GetLastWin32ErrorMessage(out var msg), msg);

            desiredStyle = IntPtr.Size == 4
                ? new IntPtr(unchecked (desiredStyle.ToInt32() & ~(int)styles))
                : new IntPtr(unchecked (desiredStyle.ToInt64() & ~(int)styles));

            var success = IntPtr.Zero != PlatformSafe.SetWindow(windowHandle, index, desiredStyle);

            WriteLineIf(!success, LastWin32ErrorMessage);
            return(success);
        }