公司的雲桌面,影響到了原生系統的“拖動時顯示窗體內容”,做了個處理程序。
感謝AI,現在查資料快速了許多。雖然的確有亂說的成分,但是慶幸的是大體思路沒問題。
using System.Runtime.InteropServices;
// 檢查當前設置
bool dragFullWindows = MsHelper.GetDragFullWindows();
Console.WriteLine("當前設置: " + (dragFullWindows ? "enable" : "disable"));
// 禁用拖動時顯示窗口內容
MsHelper.ChangeDragFullWindows(false);
await Task.Delay(500);
MsHelper.ChangeDragFullWindows(true);
// 再次檢查設置
dragFullWindows = MsHelper.GetDragFullWindows();
Console.WriteLine("更改後的設置: " + (dragFullWindows ? "enable" : "disable"));
// 啓用拖動時顯示窗口內容
//MsHelper.ChangeDragFullWindows(true);
//Console.ReadKey();
public static class MsHelper
{
[DllImport("user32.dll", SetLastError = true)]
public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, ref bool pvParam, SPIF fWinIni);
//public const uint SPI_GETDRAGFULLWINDOWS = 0x0037;
//public const uint SPI_SETDRAGFULLWINDOWS = 0x0038;
public const uint SPI_GETDRAGFULLWINDOWS = 0x0026;
public const uint SPI_SETDRAGFULLWINDOWS = 0x0025;
public static bool GetDragFullWindows()
{
bool enabled = false;
SystemParametersInfo(SPI_GETDRAGFULLWINDOWS, 0, ref enabled, 0);
return enabled;
}
public static void ChangeDragFullWindows(bool enable)
{
SystemParametersInfo(SPI_SETDRAGFULLWINDOWS, enable ? 1u : 0, ref enable, SPIF.SPIF_SENDCHANGE);
}
}
[Flags]
public enum SPIF
{
SPIF_NONE = 0,
SPIF_SENDCHANGE = 0x2,
SPIF_UPDATEINIFILE = 0x1
}