Zzz – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4  
5 namespace Zzz.Utilities
6 {
7 public static class Helpers
8 {
9 #region Public Methods
10  
11 /// <summary> Find all windows that match the given filter </summary>
12 /// <param name="filter">
13 /// A delegate that returns true for windows
14 /// that should be returned and false for windows that should
15 /// not be returned
16 /// </param>
17 public static IEnumerable<IntPtr> FindWindows(Natives.EnumWindowsProc filter)
18 {
19 var windows = new List<IntPtr>();
20  
21 Natives.EnumWindows(delegate(IntPtr wnd, IntPtr param)
22 {
23 if (filter(wnd, param))
24 {
25 // only add the windows that pass the filter
26 windows.Add(wnd);
27 }
28  
29 // but return true here so that we iterate all windows
30 return true;
31 }, IntPtr.Zero);
32  
33 return windows;
34 }
35  
36 public static string GetWindowTitle(IntPtr hWnd)
37 {
38 var length = Natives.GetWindowTextLength(hWnd) + 1;
39 var title = new StringBuilder(length);
40 Natives.GetWindowText(hWnd, title, length);
41 return title.ToString();
42 }
43  
44 #endregion
45 }
46 }