我创建了一个简单的WPF应用程序,用于启用和禁用aero shake行为。我的代码是这样的:
using System.Windows;
using System.Runtime.InteropServices;
namespace TestDisableShaking
{
public partial class MainWindow : Window
{
const uint DWM_EC_DISABLECOMPOSITION = 0;
const uint DWM_EC_ENABLECOMPOSITION = 1;
[DllImport("dwmapi.dll", EntryPoint = "DwmEnableComposition")]
extern static uint DwmEnableComposition(uint compositionAction);
[DllImport("dwmapi.dll", EntryPoint = "DwmEnableComposition")]
protected static extern uint Win32DwmEnableComposition(uint uCompositionAction);
public MainWindow()
{
InitializeComponent();
DwmEnableComposition(DWM_EC_DISABLECOMPOSITION);
Win32DwmEnableComposition(DWM_EC_DISABLECOMPOSITION);
}
}
}
为什么我的代码不起作用?
此应用程序现在执行的操作: 当我摇动窗户时,其他窗户被最小化。
我想做什么: 当我摇动窗户或摇动任何窗户时,不应将窗户最小化。
答案 0 :(得分:5)
试试这个:
[DllImport("User32.dll")]
private static extern bool SystemParametersInfo(uint iAction, uint iParameter, ref uint pParameter, uint iWinIni);
[DllImport("User32.dll")]
private static extern bool SystemParametersInfo(uint iAction, uint iParameter, uint pParameter, uint iWinIni);
和
SystemParametersInfo(0x0083, (Convert.ToUInt32(0)), (Convert.ToUInt32(0)), Convert.ToUInt32(1));