Click here to Skip to main content
15,505,667 members
Home / Discussions / C#
   

C#

 
GeneralRe: Unable to set program icon Pin
yeah100020-Sep-09 21:15
yeah100020-Sep-09 21:15 
QuestionMultiThreading in c# Pin
nisharafic18-Sep-09 0:51
nisharafic18-Sep-09 0:51 
AnswerRe: MultiThreading in c# Pin
stancrm18-Sep-09 1:01
stancrm18-Sep-09 1:01 
AnswerRe: MultiThreading in c# Pin
Jacobb Michael18-Sep-09 2:01
Jacobb Michael18-Sep-09 2:01 
QuestionThread Performance Pin
Member 368144318-Sep-09 0:47
Member 368144318-Sep-09 0:47 
AnswerRe: Thread Performance Pin
Nicholas Butler18-Sep-09 1:12
sitebuilderNicholas Butler18-Sep-09 1:12 
AnswerRe: Thread Performance Pin
Luc Pattyn18-Sep-09 3:08
sitebuilderLuc Pattyn18-Sep-09 3:08 
QuestionWeb Browser Event Hook - Problems Pin
Jacobb Michael18-Sep-09 0:31
Jacobb Michael18-Sep-09 0:31 
Hi all, I have some issues on Registering event, If you have any idea on my implementation please help me …

private SHDocVw.InternetExplorer browser;
HTMLDocument document;
HTMLDocumentEvents2_Event DocEvents;


This Event Fires well, when ever I click on any link the event is fired no issue on that. But when I click on the Text box the focus losts.

browser = (SHDocVw.InternetExplorer)pDisp;
DocEvents = (mshtml.HTMLDocumentEvents2_Event)document;
DocEvents.onclick += new HTMLDocumentEvents2_onclickEventHandler(DocEvents_onclick);


To over come this issues I have just implemented from one of the articles like bellow

  // The delegate:
    public delegate void DHTMLEvent(IHTMLEventObj e);

    ///
    /// Generic Event handler for HTML DOM objects.
    /// Handles a basic event object which receives an IHTMLEventObj which
    /// applies to all document events raised.
    ///
    [ComVisible(false)]
    public class DHTMLEventHandler
    {
        public DHTMLEvent Handler;
        mshtml.HTMLDocument Document;
        public DHTMLEventHandler(mshtml. HTMLDocument doc)
        {
            this.Document = doc;
        }
        [DispId(0)]
        public void Call()
        {
            Handler(Document.parentWindow.@event);
        }
    }

browser = (SHDocVw.InternetExplorer)pDisp;
                mshtml.HTMLDocument doc = (mshtml.HTMLDocument)browser.Document;
                DHTMLEventHandler Handler = new DHTMLEventHandler(doc);
                Handler.Handler += new DHTMLEvent(this.myCallback);
                doc.onclick = Handler;


but it shows the bello error.

Ambiguity between 'mshtml.DispHTMLDocument.onclick' and 'mshtml.HTMLDocumentEvents_Event.onclick

So I have changed from mshtml.HTMLDocument to mshtml.DispHTMLDocument

Now there is no compilation error but while excecuting it shows the bellow error

System.NotImplementedException , NotImplemented “\r\n”

Somewhat I got the information that we have to use mshtml. IHTMLDocument2 So I have used as bellow

public delegate void DHTMLEvent(mshtml.IHTMLEventObj e);

        [ComVisible(true)]
        public class DHTMLEventHandler
        {
            public DHTMLEvent Handler;
            mshtml.IHTMLDocument2 Document;

            public DHTMLEventHandler(mshtml.IHTMLDocument2 doc)
            {
                this.Document = doc;
            }

            [DispId(0)]
            public void Call()
            {
                Handler(Document.parentWindow.@event);
            }

        }

  DispHTMLDocument dispDoc = (mshtml.DispHTMLDocument)browser.Document;
                mshtml.IHTMLDocument2 doc = (mshtml.IHTMLDocument2)browser.Document;
                DHTMLEventHandler Handler = new DHTMLEventHandler(doc);
                Handler.Handler += new DHTMLEvent(this.myCallback);
                dispDoc.onclick = Handler;


public void myCallback(IHTMLEventObj evo)
        {
            // Do useful stuff...
        }


Now this runs good, but no event is fired while I click on the browser

If some one has any observation on that please guide me how to go with this. I am able to use IHTMLElementCollection and add events for each and every IHTMLElement But I am not interest in loop through all the elements and register events for each and every elements, rather want to regisert an event for a Document and from that I want to identify which element is clicked.

There are type of approaches.W3C Document Object Event Model.and Microsoft Event Object Model.

I think we can achieve the issues using Event Register and Bubbling
I know little bit on concept wise but not able to implement

If some one helps me … then it will be helpful for many…

Plese free to post your comments on that

Thanks for every one (those who involves in it)
AnswerRe: Web Browser Event Hook - Problems Pin
omizyurko6-Jun-11 3:21
omizyurko6-Jun-11 3:21 
AnswerRe: Web Browser Event Hook - Problems Pin
j to the 4n8-Nov-13 1:05
j to the 4n8-Nov-13 1:05 
QuestionHelp making threads work in C# similar to Java Pin
Cruces18-Sep-09 0:17
Cruces18-Sep-09 0:17 
AnswerRe: Help making threads work in C# similar to Java Pin
Nicholas Butler18-Sep-09 1:19
sitebuilderNicholas Butler18-Sep-09 1:19 
GeneralRe: Help making threads work in C# similar to Java Pin
Cruces18-Sep-09 3:14
Cruces18-Sep-09 3:14 
GeneralRe: Help making threads work in C# similar to Java Pin
Nicholas Butler18-Sep-09 5:17
sitebuilderNicholas Butler18-Sep-09 5:17 
GeneralRe: Help making threads work in C# similar to Java Pin
Cruces18-Sep-09 5:33
Cruces18-Sep-09 5:33 
QuestionHow can we set formats of excel sheet Pin
Gunjan pandey18-Sep-09 0:16
Gunjan pandey18-Sep-09 0:16 
QuestionDraw Controls in Layers Pin
softwarejaeger17-Sep-09 23:52
softwarejaeger17-Sep-09 23:52 
QuestionDatagridview refreshes automatically reflecting changes in database? Pin
LordZoster17-Sep-09 22:54
LordZoster17-Sep-09 22:54 
AnswerRe: Datagridview refreshes automatically reflecting changes in database? Pin
Christian Graus17-Sep-09 22:56
mveChristian Graus17-Sep-09 22:56 
AnswerRe: Datagridview refreshes automatically reflecting changes in database? Pin
Tamer Oz17-Sep-09 23:05
Tamer Oz17-Sep-09 23:05 
GeneralRe: Datagridview refreshes automatically reflecting changes in database? Pin
Christian Graus17-Sep-09 23:07
mveChristian Graus17-Sep-09 23:07 
GeneralRe: Datagridview refreshes automatically reflecting changes in database? Pin
Tamer Oz17-Sep-09 23:15
Tamer Oz17-Sep-09 23:15 
GeneralRe: Datagridview refreshes automatically reflecting changes in database? Pin
LordZoster17-Sep-09 23:17
LordZoster17-Sep-09 23:17 
GeneralRe: Datagridview refreshes automatically reflecting changes in database? Pin
Tamer Oz17-Sep-09 23:22
Tamer Oz17-Sep-09 23:22 
GeneralRe: Datagridview refreshes automatically reflecting changes in database? Pin
Christian Graus17-Sep-09 23:23
mveChristian Graus17-Sep-09 23:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.