Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在屏幕上显示所有窗口?_C#_Interop_Pinvoke_Win32 Process - Fatal编程技术网

C# 如何在屏幕上显示所有窗口?

C# 如何在屏幕上显示所有窗口?,c#,interop,pinvoke,win32-process,C#,Interop,Pinvoke,Win32 Process,上个月我问了一个类似的问题,但不幸的是,我没有得到一个关于这个问题的答复。我再问一遍。 在我的一个项目中,我想让所有窗口都显示在屏幕上。我试过这个密码 正如你所看到的,我已经为McUICnt,devenv开了一张支票。placement.cmd==1检查处于正常状态的窗口。但McUICnt和devenv也通过了该条件,但没有显示在屏幕上。当我再次运行程序时,我得到了如上所述的新进程。 如何让所有窗口立即显示在屏幕上? 更新: 当我使用EnumWindows时,我使用此代码 及 但它也显示最小化的

上个月我问了一个类似的问题,但不幸的是,我没有得到一个关于这个问题的答复。我再问一遍。 在我的一个项目中,我想让所有窗口都显示在屏幕上。我试过这个密码

正如你所看到的,我已经为McUICnt,devenv开了一张支票。placement.cmd==1检查处于正常状态的窗口。但McUICnt和devenv也通过了该条件,但没有显示在屏幕上。当我再次运行程序时,我得到了如上所述的新进程。 如何让所有窗口立即显示在屏幕上? 更新: 当我使用EnumWindows时,我使用此代码


但它也显示最小化的窗口。甚至我也选中了IsWindowVisible

调用EnumWindows以获取所有顶级windows@DavidHeffernan请看我的编辑。我试过你的建议了。太好了。“我很高兴它起作用了。”大卫·费弗南:是的,它对我起作用了。但它也显示最小化的窗口。甚至我也检查了IsWindowVisible。使用IsIconic测试最小化的窗口
Process[] procs = Process.GetProcesses();
if (proc.MainWindowHandle!=IntPtr.Zero)
                {

                GetWindowPlacement(proc.MainWindowHandle, ref placement);
                if (proc.ProcessName!="McUICnt" && proc.ProcessName!="devenv" && proc.ProcessName!="DCSHelper" && proc.ProcessName!="explorer")
                {
                    if (placement.showCmd == 1)
                    {
                        handles[temp] = proc.MainWindowHandle;
                        GetWindowRect(proc.MainWindowHandle, ref rct);
                        rect[temp] = rct;
                        temp++;
                        MessageBox.Show(proc.ProcessName.ToString());
                    }
                }

                }
EnumWindows(new EnumWindowsProc(EnumTheWindows), IntPtr.Zero);
protected static bool EnumTheWindows(IntPtr hWnd, IntPtr lParam)
        {

            int size = GetWindowTextLength(hWnd);
            RECT rct = new RECT();
            if (size++ > 0 && IsWindowVisible(hWnd))
            {
                StringBuilder sb = new StringBuilder(size);
                GetWindowText(hWnd, sb, size);
                MessageBox.Show(sb.ToString());
                handles[tempHandle] = hWnd;
                GetWindowRect(hWnd, ref rct);
                rect[tempHandle] = rct;
                tempHandle++;

            }
            return true;
        }