public static IntPtr ControlExistsHandle(IntPtr Parent, string HWNDTitle, string HWNDClass) { List <IntPtr> result = new List <IntPtr>(); GCHandle listHandle = GCHandle.Alloc(result); EnumChildProcDelegate childProc = new EnumChildProcDelegate(EnumChildProc); EnumChildWindows(Parent, childProc, GCHandle.ToIntPtr(listHandle)); foreach (IntPtr Handle in result) { GetClassName(Handle, Class, nChars); GetWindowText(Handle, Title, nChars); if (Title.ToString().Contains(HWNDTitle) & Class.ToString().Contains(HWNDClass)) { return(Handle); } } return(IntPtr.Zero); }
public static extern bool EnumChildWindows(IntPtr hwndParent, EnumChildProcDelegate lpEnumFunc, IntPtr lParam);