From 8305327db52dadc52086e1263319bd7688a219e5 Mon Sep 17 00:00:00 2001 From: RKrom Date: Fri, 17 Aug 2012 09:11:50 +0000 Subject: [PATCH] Extension of the document function, it now also accepts the "Internet Explorer_Server" window directly, this can increase the performance for coming changes. git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1999 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4 --- Greenshot/Helpers/IECaptureHelper.cs | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/Greenshot/Helpers/IECaptureHelper.cs b/Greenshot/Helpers/IECaptureHelper.cs index 8e0be8415..4458c33a1 100644 --- a/Greenshot/Helpers/IECaptureHelper.cs +++ b/Greenshot/Helpers/IECaptureHelper.cs @@ -138,7 +138,7 @@ namespace Greenshot.Helpers { } else { List singleWindowText = new List(); try { - IHTMLDocument2 document2 = getDocument(ieWindow); + IHTMLDocument2 document2 = getHTMLDocument(ieWindow); string title = document2.title; if (string.IsNullOrEmpty(title)) { singleWindowText.Add(ieWindow.Text); @@ -171,7 +171,18 @@ namespace Greenshot.Helpers { /// /// /// - private static IHTMLDocument2 getDocument(WindowDetails mainWindow) { + private static IHTMLDocument2 getHTMLDocument(WindowDetails mainWindow) { + WindowDetails ieServer; + if ("Internet Explorer_Server".Equals(mainWindow.ClassName)) { + ieServer = mainWindow; + } else { + ieServer = mainWindow.GetChild("Internet Explorer_Server"); + } + if (ieServer == null) { + LOG.WarnFormat("No Internet Explorer_Server for {0}", mainWindow.Text); + return null; + } + IHTMLDocument2 document2 = null; uint windowMessage = User32.RegisterWindowMessage("WM_HTML_GETOBJECT"); if (windowMessage == 0) { @@ -179,11 +190,6 @@ namespace Greenshot.Helpers { return null; } - WindowDetails ieServer = mainWindow.GetChild("Internet Explorer_Server"); - if (ieServer == null) { - LOG.WarnFormat("No Internet Explorer_Server for {0}", mainWindow.Text); - return null; - } LOG.DebugFormat("Trying WM_HTML_GETOBJECT on {0}", ieServer.ClassName); UIntPtr response; User32.SendMessageTimeout(ieServer.Handle, windowMessage, IntPtr.Zero, IntPtr.Zero, SendMessageTimeoutFlags.SMTO_NORMAL, 5000, out response); @@ -207,7 +213,7 @@ namespace Greenshot.Helpers { /// The WindowDetails to get the IHTMLDocument2 for /// Ref to the IHTMLDocument2 to return /// The WindowDetails to which the IHTMLDocument2 belongs - private static DocumentContainer GetDocument(WindowDetails browserWindow) { + private static DocumentContainer CreateDocumentContainer(WindowDetails browserWindow) { DocumentContainer returnDocumentContainer = null; WindowDetails returnWindow = null; IHTMLDocument2 returnDocument2 = null; @@ -235,7 +241,7 @@ namespace Greenshot.Helpers { try { // Get the Document - IHTMLDocument2 document2 = getDocument(ieWindow); + IHTMLDocument2 document2 = getHTMLDocument(ieWindow); if (document2 == null) { continue; } @@ -337,7 +343,7 @@ namespace Greenshot.Helpers { //BackgroundForm backgroundForm = BackgroundForm.ShowAndWait(language.GetString(LangKey.contextmenu_captureie), language.GetString(LangKey.wait_ie_capture)); try { //Get IHTMLDocument2 for the current active window - DocumentContainer documentContainer = GetDocument(windowToCapture); + DocumentContainer documentContainer = CreateDocumentContainer(windowToCapture); // Nothing found if (documentContainer == null) {