简体   繁体   中英

get all opened forms, c#?

I need to use Windows7.DesktopIntegration.WindowsFormsExtensions functions, such as WindowsFormsExtensions.SetTaskbarProgress, with some opened forms. These forms are not opened by my application.

How to get link to Form object of each window? Or maybe there is another way to use these taskbar functions?

i've found a way:

        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)
            );
        }

Form objects only exists for those forms created by your own application.

Windows created by other applications only have handles, as far as you can tell.

It might be possible to construct Form objects around existing handles, but I'd say that this is probably not the best way to do it.

Why are you trying to control properties on other forms like that, what is it that you're trying to do?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM