SetForegroundWindow doesn't work with minimized process [duplicate]

a 夏天 提交于 2019-12-04 17:00:31
Erik Philips

You are going to need to call ShowWindow before you try to set it as the foreground window.

Probably with SW_RESTORE:

 [DllImport("user32.dll")]
 [return: MarshalAs(UnmanagedType.Bool)]
 static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

 if (p.Length > 0)
 {
   ShowWindow(p[0].MainWindowHandle, 9);
   SetForegroundWindow(p[0].MainWindowHandle);
 }

PInvoke.net - ShowWindow has some examples on DllImport and using the function in C#.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!