【问题标题】:get all opened forms, c#?获取所有打开的表单,c#?
【发布时间】:2009-09-22 18:00:26
【问题描述】:

我需要对一些打开的表单使用 Windows7.DesktopIntegration.WindowsFormsExtensions 函数,例如 WindowsFormsExtensions.SetTaskbarProgress。我的应用程序没有打开这些表单。

如何获取每个窗口的表单对象的链接?或者也许还有其他方法可以使用这些任务栏功能?

【问题讨论】:

    标签: c# forms windows-7 taskbar


    【解决方案1】:

    我找到了办法:

            WindowsFormsExtensions.SetAppId(this, "totalcmd");
            Process[] processes = Process.GetProcessesByName("TOTALCMD");
            foreach (Process p in processes)
            {
                IntPtr pFoundWindow = p.MainWindowHandle;
                //MessageBox.Show(p.ProcessName);
    
                Windows7.DesktopIntegration.Windows7Taskbar.SetWindowAppId(pFoundWindow, "totalcmd");
                MessageBox.Show(
                    Windows7.DesktopIntegration.Windows7Taskbar.GetWindowAppId(pFoundWindow)
                );
            }
    

    【讨论】:

      【解决方案2】:

      表单对象仅存在于您自己的应用程序创建的表单中。

      据您所知,由其他应用程序创建的窗口只有句柄。

      可能可以围绕现有句柄构造 Form 对象,但我想说这可能不是最好的方法。

      你为什么要像那样控制其他表单上的属性,你要做什么?

      【讨论】:

      • hmm 那么我该如何更改其他应用程序的 AppId? WindowsFormsExtensions.SetAppId 想要一个 Form 对象作为参数
      • 使用 Windows 7 的托管扩展,您可能不能,但它们可能是 Win32/64 API 函数之上的托管层,可能只需要句柄。
      猜你喜欢
      • 2017-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-12
      • 1970-01-01
      • 2014-08-27
      • 2017-03-18
      相关资源
      最近更新 更多