打开一扇窗户 [英] Bring up a window

查看:75
本文介绍了打开一扇窗户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过点击c#

解决方案

iVyperon,按钮,让应用程序在前面板上运行p>

是否要单击按钮使正在运行的进程成为活动窗口?如果是,您可以查看以下代码。我点击按钮使记事本活动窗口。

 [DllImport(" user32.dll")] 
static extern bool SetForegroundWindow(IntPtr hWnd);
private void button2_Click(object sender,EventArgs e)
{
System.Diagnostics.Process [] p = System.Diagnostics.Process.GetProcessesByName(" notepad");
if(p.Length> 0)
{
SetForegroundWindow(p [0] .MainWindowHandle);
}
}

祝你好运,


Cherry







How do i get a application to run on the frontscreen by clicking on a button in c#

解决方案

Hi iVyperon,

Do you want to click button to make a running process the active Window? If yes, you can take a look the following code. I click button to make notepad active window.

[DllImport("user32.dll")]
        static extern bool SetForegroundWindow(IntPtr hWnd);
        private void button2_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process[] p = System.Diagnostics.Process.GetProcessesByName("notepad");
            if (p.Length > 0)
            {
                SetForegroundWindow(p[0].MainWindowHandle);
            }
        }

Best regards,

Cherry



这篇关于打开一扇窗户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆