public static IHTMLDocument2 DocumentFromDOM(IntPtr hWnd) { IHTMLDocument2 document = null; int lngMsg = 0; int lRes; Win32.EnumProc proc = new Win32.EnumProc(DOM.EnumWindows); Win32.EnumChildWindows(hWnd, proc, ref hWnd); if (!hWnd.Equals(IntPtr.Zero)) { lngMsg = Win32.RegisterWindowMessage("WM_HTML_GETOBJECT"); if (lngMsg != 0) { Win32.SendMessageTimeout(hWnd, lngMsg, 0, 0, Win32.SMTO_ABORTIFHUNG, 1000, out lRes); if (!(bool)(lRes == 0)) { int hr = Win32.ObjectFromLresult(lRes, ref Win32.IID_IHTMLDocument2, 0, ref document); if ((bool)(document == null)) { //MessageBox.Show("No IHTMLDocument Found!", "Warning"); Console.WriteLine("No IHTMLDocument Found!"); } } } } return(document); }
public static IHTMLDocument2 DocumentFromDOM(IntPtr hWnd) { IHTMLDocument2 document = null; int lngMsg = 0; int lRes; Win32.EnumProc proc = new Win32.EnumProc(DOM.EnumWindows); Win32.EnumChildWindows(hWnd, proc, ref hWnd); if (!hWnd.Equals(IntPtr.Zero)) { lngMsg = Win32.RegisterWindowMessage("WM_HTML_GETOBJECT"); if (lngMsg != 0) { Win32.SendMessageTimeout(hWnd, lngMsg, 0, 0, Win32.SMTO_ABORTIFHUNG, 1000, out lRes); if (!(bool)(lRes == 0)) { int hr = Win32.ObjectFromLresult(lRes, ref Win32.IID_IHTMLDocument2, 0, ref document); if ((bool)(document == null)) { //MessageBox.Show("No IHTMLDocument Found!", "Warning"); Console.WriteLine("No IHTMLDocument Found!"); } } } } return document; }