本文介绍了把转发窗口最小化时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道如何提出一个特定的窗口。
时,没有最小化窗口SetForegroundWindow的作品!但是当一个最小化窗口,SetForegroundWindow不起作用...
这我的代码:
INT IdRemoto = int.Parse(textBoxID.Text);
过程[] = PROCESSLIST Process.GetProcessesByName(AA_v3.3);
的foreach(在PROCESSLIST工艺过程)
{
如果(!String.IsNullOrEmpty(process.MainWindowTitle))
{
如果(IdRemoto.ToString ()== process.MainWindowTitle)
SetForegroundWindow(process.MainWindowHandle);
}
}
函数[DllImport(user32.dll中)]
私人静态的extern BOOL SetForegroundWindow(IntPtr的的hWnd);
解决方案
您可以检查是否正在使用最小化窗口在IsIconic()API,然后使用的ShowWindow()将其恢复为Houssem作为已经显示:
公共const int的SW_RESTORE = 9 ;
函数[DllImport(user32.dll中)]
公共静态外部布尔IsIconic(IntPtr的手柄);
函数[DllImport(user32.dll中)]
公共静态外部布尔的ShowWindow(IntPtr的处理,诠释的nCmdShow);
函数[DllImport(user32.dll中)]
公共静态外部INT SetForegroundWindow(IntPtr的手柄);
私人无效BringToForeground(IntPtr的extHandle)
{
如果(IsIconic(extHandle))
{
的ShowWindow(extHandle,SW_RESTORE);
}
SetForegroundWindow(extHandle);
}
I want to know how to bring forward a particular window.SetForegroundWindow works when the window is not minimized!! but when a minimize the window, SetForegroundWindow doesn't work...
this my code:
int IdRemoto = int.Parse(textBoxID.Text);
Process[] processlist = Process.GetProcessesByName("AA_v3.3");
foreach (Process process in processlist)
{
if (!String.IsNullOrEmpty(process.MainWindowTitle))
{
if (IdRemoto.ToString() == process.MainWindowTitle)
SetForegroundWindow(process.MainWindowHandle);
}
}
[DllImport("user32.dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
解决方案
You can check to see if the window is minimized using the IsIconic() API, then use ShowWindow() to restore it as Houssem as already shown:
public const int SW_RESTORE = 9;
[DllImport("user32.dll")]
public static extern bool IsIconic(IntPtr handle);
[DllImport("user32.dll")]
public static extern bool ShowWindow(IntPtr handle, int nCmdShow);
[DllImport("user32.dll")]
public static extern int SetForegroundWindow(IntPtr handle);
private void BringToForeground(IntPtr extHandle)
{
if (IsIconic(extHandle))
{
ShowWindow(extHandle, SW_RESTORE);
}
SetForegroundWindow(extHandle);
}
这篇关于把转发窗口最小化时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!