Click here to Skip to main content
16,017,297 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am using webbrowser control to bind the html & text files data.
In that i want 2 options like Document click and Double click event.
In CLick event I want to retrieve the click position "word", and in the double click event I want to retrieve the "Sentance".

This is working fine for some files but some file it is not working properlly.

Here Iam not able to attach my code but the CLick event and double click event funtionality is
Click Event:
C#
IHTMLDocument2 doc = (IHTMLDocument2)wbDocument.Document.DomDocument;
                IHTMLSelectionObject sel = (IHTMLSelectionObject)doc.selection;
                IHTMLTxtRange rng = (IHTMLTxtRange)sel.createRange();
                if (rng != null)
                {
                    rng.expand("word");
                    if (rng.text != null)
                    {
                        rng.@select();

                        if (rng.text.Trim() != "")
                        {
                            selectedWordorSentance = rng.text;
                            if (timer1.Enabled)
                            {
                                timer1.Stop();
                            }
                            timer1.Interval = 500;
                            timer1.Start();
                        }
                    }
                }

Double click event:
C#
IHTMLDocument2 doc = (IHTMLDocument2)wbDocument.Document.DomDocument;
                IHTMLSelectionObject sel = (IHTMLSelectionObject)doc.selection;
                IHTMLTxtRange rng = (IHTMLTxtRange)sel.createRange();
                if (rng != null)
                {
                    rng.expand("sentence");
                    if (rng.text != null)
                    {
                        rng.@select();
                        if (timer1.Enabled)
                        { 
                            timer1.Stop(); 
                        }
                        selectedWordorSentance = rng.text;
                        ShowSelectedWordOrSentance();
                    }
                }
Posted
Updated 13-Sep-11 19:24pm
v2
Comments
Prerak Patel 14-Sep-11 1:24am    
Added code blocks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900