- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我想将窗口窗体显示为弹出窗口,出现在所有打开的其他应用程序窗口的顶部我使用了 Focus
方法,但它没有用。所以我试过了:
using System.Diagnostics;
using System.Runtime.InteropServices;
// Sets the window to be foreground
[DllImport("User32")]
private static extern int SetForegroundWindow(IntPtr hwnd);
// Activate or minimize a window
[DllImportAttribute("User32.DLL")]
private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
private const int SW_SHOW = 5;
private const int SW_MINIMIZE = 6;
private const int SW_RESTORE = 9;
private void ActivateApplication(string briefAppName)
{
Process[] procList = Process.GetProcessesByName(briefAppName);
if (procList.Length > 0)
{
ShowWindow(procList[0].MainWindowHandle, SW_RESTORE);
SetForegroundWindow(procList[0].MainWindowHandle);
}
}
如前一个关于 SO Here 的问题所述但我无法使用它。正确答案海报说“基本上,调用 ShowWindow() 然后调用 SetForegroundWindow()。
”但我不知道这些方法的参数是什么
我究竟应该将什么传递给 ShowWindow();
和 SetForegroundWindow();方法??有帮助吗?
最佳答案
这是我的解决方案:
private void ActivateApplication (string briefAppName)
{
Process[] p=Process.GetProcessesByName (briefAppName);
if (p.Length>0)
{
this.TopMost=true;
ShowWindow (p[0].MainWindowHandle, 9);
this.TopMost=false;
this.Activate ();
}
}
使用 .Activate () 来聚焦表单,使用 TopMost 来改变表单的 Always-on-top 状态。
9 表示 Resotre 窗口。如果您的窗口已经恢复,则 ShowWindow 函数将不执行任何操作。在此处查找 ShowWindow 函数的文档:http://msdn.microsoft.com/en-us/library/windows/desktop/ms633548%28v=vs.85%29.aspx
关于c# - 在当前打开的应用程序的顶部显示隐藏的窗体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12340837/
对于一个科学实验,我写了一个turtle.py ,它会打开一个 800x480 的窗口并绘制一个缓慢增长的黑点。 turtle.py以 C:\Users\kaza>python C:\Users\ka
我开发了一个 swing 应用程序,但每次运行应用程序时都会打开一个新窗口。我希望如果一个窗口已经打开,则其他窗口不允许打开。 最佳答案 Here是一个 Java 单一应用实例的例子: A singl
有没有办法检测主进程中 Electron 的结构? process.platform 似乎也在 x64 机器上返回 win32,我没有在文档中找到任何获取架构的选项。 最佳答案 你试过 process
public short[] HanningWindow(short[] signal_in ,int pos ,int size) { for (int i= pos; i < pos+si
我有一个具有这些属性的 Electron 窗口: mainWindow = new BrowserWindow({ width: 800, height: 600, title: "Aqu
我有一个 Ubuntu 工作站,我正在尝试引导一个 Windows 节点。 Windows 节点在端口 2222 上打开了 ssh。我一直在关注 http://docs.opscode.com/plu
我是一名优秀的程序员,十分优秀!