Thursday, February 21, 2008

Handle Active Tab and Screen Capture in IE6 & IE7

SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindowsClass();

IntPtr activeWindowHandle;
mshtml.IHTMLDocument2 myDoc;
mshtml.IHTMLDocument3 myDoc1;
activeWindowHandle = GetForegroundWindow();
IntPtr myIntptr = activeWindowHandle;
int hwndInt = myIntptr.ToInt32();
IntPtr hwnd = myIntptr;
IntPtr hwnd1 = IntPtr.Zero;
hwnd = GetWindow(hwnd, GW_CHILD);
StringBuilder sbc = new StringBuilder(256);
IEnumerator windows = new SHDocVw.ShellWindowsClass().GetEnumerator();
while (windows.MoveNext())
{
if ((windows.Current is SHDocVw.IWebBrowser2) && ((windows.Current as SHDocVw.IWebBrowser2).HWND.ToString() == activeWindowHandle.ToString()))
{
((windows.Current as SHDocVw.IWebBrowser2).Document as IOleWindow).GetWindow(out hwnd);

if (IsWindowVisible(hwnd))
{
break;
}
}
}
myDoc = ((windows.Current as SHDocVw.IWebBrowser2).Document as mshtml.IHTMLDocument2);
myDoc1 = ((windows.Current as SHDocVw.IWebBrowser2).Document as mshtml.IHTMLDocument3);

No comments: