Ich würde gerne wissen, wie die Animationen beim Aufruf der HWnd ShowWindow() -Methode unterdrückt werden. Hier ist mein Code:HWND API: So deaktivieren Sie Fensteranimationen beim Aufruf von ShowWindow (...)
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool ShowWindow(IntPtr hWnd, ShowWindowCommands nCmdShow);
public enum ShowWindowCommands
{
HIDE = 0,
SHOWNORMAL = 1,
SHOWMINIMIZED = 2,
MAXIMIZE = 3,
SHOWNOACTIVATE = 4,
SHOW = 5,
MINIMIZE = 6,
SHOWMINNOACTIVE = 7,
SHOWNA = 8,
RESTORE = 9,
SHOWDEFAULT = 10,
FORCEMINIMIZE = 11
}
public static void MinimizeWindow(IntPtr hWnd)
{
ShowWindow(hWnd, ShowWindowCommands.MINIMIZE);
}
Das Problem ist, die Animation ausgeführt wird, und die Methode nicht zurück, bis die Animation beendet ist.
Ich versuchte, die DwmSetWindowAttribute() Methode:
[DllImport("dwmapi.dll", PreserveSig = true)]
static extern int DwmSetWindowAttribute(IntPtr hWnd, uint attr, ref int attrValue, int size);
const uint DWM_TransitionsForceDisabled = 3;
public static void SetEnabled(IntPtr hWnd, bool enabled)
{
int attrVal = enabled ? 0 : 1;
DwmSetWindowAttribute(hWnd, DWM_TransitionsForceDisabled, ref attrVal, 4);
}
Aber die Animationen nicht unterdrückt wurden. Mein Betriebssystem ist Windows 7, 32-Bit.
Überprüfen Sie den Rückgabewert von 'DwmSetWindowAttribute', um zu sehen, ob es fehlschlägt und wenn ja, warum. –
@ Jonathan Potter Der Rückgabewert ist Null, dh Operation erfolgreich –
Siehe die Antwort auf http://StackOverflow.com/Questions/6160118/disable-Aero-Peek-in-WPF-Application, es sieht so aus, als ob Sie die übergeben Datenzeiger falsch. –