/
githubmirror
/
PowerToys
Обзор
Документация
Войти
/
githubmirror
/
PowerToys
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/modules/powerdisplay/PowerDisplay/Helpers/WindowHelper.cs
88 строк
3 KB
Niels Laute
Refactor transparent overlay into TransparentWindow + TransientSurface (#48915)
27 июн 2026, 00:25
Не верифицирован
27 июн 2026, 00:25
fb6843b
Код
Авторство
О чём код?
// Copyright (c) Microsoft Corporation // The Microsoft Corporation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; namespace PowerDisplay.Helpers { /// <summary> /// PowerDisplay-local window helpers. Flyout positioning/sizing now lives in /// <c>Microsoft.PowerToys.Common.UI.Controls.Window.FlyoutWindowHelper</c> (Common.UI.Controls). /// </summary> internal static partial class WindowHelper { // Window Styles private const int GwlStyle = -16; private const int WsCaption = 0x00C00000; private const int WsThickframe = 0x00040000; private const int WsMinimizebox = 0x00020000; private const int WsMaximizebox = 0x00010000; private const int WsSysmenu = 0x00080000; // Extended Window Styles private const int GwlExstyle = -20; private const int WsExDlgmodalframe = 0x00000001; private const int WsExWindowedge = 0x00000100; private const int WsExClientedge = 0x00000200; private const int WsExStaticedge = 0x00020000; private const uint SwpNosize = 0x0001; private const uint SwpNomove = 0x0002; private const uint SwpFramechanged = 0x0020; // P/Invoke declarations (64-bit only - PowerToys only builds for x64/ARM64) [LibraryImport("user32.dll", EntryPoint = "GetWindowLongPtrW")] private static partial nint GetWindowLongPtr(nint hWnd, int nIndex); [LibraryImport("user32.dll", EntryPoint = "SetWindowLongPtrW")] private static partial nint SetWindowLong(nint hWnd, int nIndex, nint dwNewLong); [LibraryImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] private static partial bool SetWindowPos( nint hWnd, nint hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags); /// <summary> /// Disable window moving and resizing functionality. /// </summary> public static void DisableWindowMovingAndResizing(nint hWnd) { // Get current window style nint style = GetWindowLongPtr(hWnd, GwlStyle); // Remove resizable borders, title bar, and system menu style &= ~WsThickframe; style &= ~WsMaximizebox; style &= ~WsMinimizebox; style &= ~WsCaption; // Remove entire title bar style &= ~WsSysmenu; // Remove system menu // Set new window style _ = SetWindowLong(hWnd, GwlStyle, style); // Get extended style and remove related borders nint exStyle = GetWindowLongPtr(hWnd, GwlExstyle); exStyle &= ~WsExDlgmodalframe; exStyle &= ~WsExWindowedge; exStyle &= ~WsExClientedge; exStyle &= ~WsExStaticedge; _ = SetWindowLong(hWnd, GwlExstyle, exStyle); // Refresh window frame SetWindowPos( hWnd, 0, 0, 0, 0, 0, SwpNomove | SwpNosize | SwpFramechanged); } } }