Отправка сообщения в приложение WPF - PullRequest
1 голос
/ 11 мая 2011

Я пытаюсь отправить сообщение в приложение 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

оно не работает

Любые идеи

1 Ответ

0 голосов
/ 11 мая 2011

Вам, вероятно, лучше импортировать 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); и т. Д.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...