开发者

Sending Message to WPF app

I am trying to send a message to a WPF application to have it Minimize and then to restore

I am doing

//Import the SetForeground API to activate it
[DllImportAttribute("User32.dll")]
private static extern IntPtr SetForegroundWindow(int hWnd);

[DllImportAttribute("User32.dll")]
//private static extern IntPtr SendMes开发者_开发知识库sage(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

it does not work

Any ideas


You're probably better off importing ShowWindow rather than just 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;

You should then just be able to say ShowWindow(hWnd, SW_MINIMIZE); etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜