astadtla / csexwb2

Automatically exported from code.google.com/p/csexwb2
0 stars 0 forks source link

Focus problem - links have to be clicked twice (1.0.0.7) #18

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Open a Demo application
2. Go to coogle.com
3. click on a link.. nothing happens, 
4. click again, now it works
5. click on the url bar
6. try to click some other link to see the problem again

What is the expected output? What do you see instead?

What are the OS and IE versions?
Vista, IE7

What version of the product are you using?
1.0.0.7

Please provide any additional information below.
It seems to work in 1.0.0.3 (from the CodeProject)

Original issue reported on code.google.com by david.kr...@gmail.com on 10 Jan 2008 at 3:40

GoogleCodeExporter commented 8 years ago
Please refer to the link below for a solution. This will be part of next 
release.
http://groups.google.com/group/csexwb/browse_thread/thread/321583125a16a959

Regards,
MH

Original comment by mehr...@gmail.com on 10 Jan 2008 at 4:54

GoogleCodeExporter commented 8 years ago
Confirm. Also have this bug. Windows XP + SP3. Version 1.0.0.7.

Original comment by sec....@gmail.com on 12 May 2008 at 8:35

GoogleCodeExporter commented 8 years ago
This fix does not always work as the clicked link may be a sub component of the
current one with focus, for example if it is in an IFrame.

Original comment by tal13...@gmail.com on 7 Jul 2008 at 8:44

GoogleCodeExporter commented 8 years ago
Here is the fix that will account for frames or iframes:

1) Add next two methods to the "#region Public Method Members" of csEXWB.cs 
file 

        /// <summary>
        /// Calls click method of active element
        /// </summary>
        public void ClickActiveElement()
        {
            IHTMLElement elem = this.GetActiveElement();
            if (elem != null)
                elem.click();
        } 

        /// <summary>
        /// Attempts to return active IHTMLElement interface instance
        /// Accounts for Frames and Iframes
        /// </summary>
        /// <returns></returns>
        public IHTMLElement GetActiveElement()
        {
            IHTMLElement elem = null;
            string tagname = string.Empty;
            IHTMLDocument2 doc2 = GetActiveDocument();
            if (doc2 != null)
                elem = doc2.activeElement;
            if( (elem != null) && (!string.IsNullOrEmpty(elem.tagName)) )
                tagname = elem.tagName.ToLower();
            while ((!string.IsNullOrEmpty(elem.tagName)) &&
                ((tagname == "frame") || (tagname == "iframe")))
            {
                //Cast it to IWebBrowser2
                IWebBrowser2 pwb = elem as IWebBrowser2;
                if (pwb != null)
                {
                    //Now get the document
                    //If you attempt to access the document via 
IHTMLFrameBase2.contentWindow
                    //you will get a "Access Denied" exception
                    IHTMLDocument2 pdoc2 = pwb.Document as IHTMLDocument2;
                    if (pdoc2 != null)
                        elem = pdoc2.activeElement;
                    if ((elem != null) && (!string.IsNullOrEmpty(elem.tagName)))
                        tagname = elem.tagName.ToLower();
                    else
                        tagname = string.Empty;
                }
            }
            return elem;
        }

2) In "case WindowsMessages.WM_LBUTTONUP:" of WndProc method of IEServerWindow 
class 
(csEXWB.cs) change 

                    if (!browser.m_InternalHasFocus) 
                    { 
                        browser.Focus(); 
                    } 
To: 

                    if (!browser.m_InternalHasFocus) 
                    { 
                        browser.Focus(); 
                        browser.ClickActiveElement(); 
                    } 

This issue was resolved in V2.0.0.1

Regards,

MH

Original comment by mehr...@gmail.com on 7 Jul 2008 at 10:49