我需要对一些打开的表单使用 Windows7.DesktopIntegration.WindowsFormsExtensions 函数,例如 WindowsFormsExtensions.SetTaskbarProgress。我的应用程序没有打开这些表格。
如何获取每个窗口的 Form 对象的链接?或者也许还有另一种使用这些任务栏功能的方法?
我找到了一种方法:
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)
);
}
表单对象仅存在于您自己的应用程序创建的表单中。
据您所知,由其他应用程序创建的 Windows 只有句柄。
可以围绕现有句柄构造 Form 对象,但我想说这可能不是最好的方法。
您为什么要尝试控制其他表单上的属性,您要尝试做什么?