2011-05-11 131 views
1

我試圖將消息發送到WPF應用程序有它最小化,然後恢復發送信息給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

你用過間諜++檢查窗戶是否接收消息? – dlev 2011-05-11 16:24:51

+0

是的,我有,我看到它... - 它說WM_SHOWWINDOW fshow:false fuStatus:0我以爲我可能有一個參數錯了,但我希望它會盡量減少它不會 – Jeff 2011-05-11 16:32:00

回答

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);