public static IEnumerable<IWinApiWindow> EnumWindows(Predicate<IWinApiWindow> condition = null)
 {
     var windowsList = new List<IWinApiWindow>();
     EnumWindowsProc windowEnumDelegate = (wnd, param) =>
     {
         var window = new WinApiWindow(wnd);
         if (condition == null || condition.Invoke(window))
         {
             windowsList.Add(window);
         }
         return true;
     };
     User32.EnumWindows(windowEnumDelegate, IntPtr.Zero);
     return windowsList;
 }
示例#2
0
 private void button2_Click(object sender, EventArgs e)
 {
     var index = listBox1.SelectedIndex;
     var window = WinApiWindow.EnumWindows(win => (win.IsDesktopWindow || win.IsToolWindow) && win.Title != null).ToList()[index];
     var currentWindow = new WinApiWindow(Handle)
     {
         Parent = window
     };
 }