我正在尝试向WPF应用程序发送消息以使其最小化然后恢复
我在做
//Import the SetForeground API to activate it
[DllImportAttribute("User32.dll")]
private static extern IntPtr SetForegroundWindow(int hWnd);
[DllImportAttribute("User32.dll")]
//private static extern IntPtr SendMessage(int hWnd, int Msg, bool wParam, int lParam);
private static extern IntPtr SendMessage(int hWnd, uint Msg, UIntPtr wParam, IntPtr lParam);
....
SetForegroundWindow(hWnd); //Activate it
//in here I minimize the window manually
SendMessage(hWnd, 0x0018, (UIntPtr)0, (IntPtr)0); //trying to restore
它不起作用
任何想法
答案 0 :(得分:0)
您最好不要导入ShowWindow而不仅仅是SendMessage:
[DllImportAttribute("User32.dll")]
private static extern IntPtr ShowWindow(int hWnd, int showFlag);
public const int SW_MINIMIZE = 0x06;
pubilc const int SW_RESTORE = 0x09;
public const int SW_FORCEMINIMIZE = 0x0B;
然后您应该只能说ShowWindow(hWnd, SW_MINIMIZE);
等。