2017-12-01 14 views
0

私はC#を初めて使用しています。IEBrowserを開いて読み込んだコードを書いています。InternetExplorer C#でDocumentCompleteEventHandlerが起動しない

あなたはここで

下のメインのコードが表示されている場合は、私のコードです:

public delegate void DocumentCompleteEventHandler(SHDocVw.InternetExplorer IE); 
class Program{ 
    private static string m_autoLoginFormContents = null; 
    private static SHDocVw.InternetExplorer m_autologinIEWindow; 
    static SHDocVw.DWebBrowserEvents2_DocumentCompleteEventHandler m_AutoLoginDocCompleteHandler; 
    private static SHDocVw.DWebBrowserEvents2_DocumentCompleteEventHandler m_documentCompleteEventHandler; 
    public static event DocumentCompleteEventHandler DocumentComplete; 

    static void Main(string[] args) 
    { 
     m_documentCompleteEventHandler = new SHDocVw.DWebBrowserEvents2_DocumentCompleteEventHandler(DocumentCompleteEventHandler); 
     m_autologinIEWindow = OpenIEWindowToURL("about:blank"); 
     m_autologinIEWindow.DocumentComplete += m_AutoLoginDocCompleteHandler; 
     m_AutoLoginDocCompleteHandler = new SHDocVw.DWebBrowserEvents2_DocumentCompleteEventHandler(URLAutologinDocumentCompleteEventHandler); 

     System.Console.Read(); 
    } 

    public static void URLAutologinDocumentCompleteEventHandler(object senderObject, ref object objectTwo /* not sure what this argument is for */) 
    { 
     //Something 
    } 

    private static void DocumentCompleteEventHandler(object senderObject, ref object objectTwo /* not sure what this argument is for */) 
    { 
      //Something 
    } 
} 

、必要に応じてIEのウィンドウが空白のページを開きますが、イベントが解雇されることはありません、ofcourseの私はやっています何か間違っています。私はスーパーで、おそらくC#の最初のコードです。

答えて

2

コードをシンプルにして、以下のようにしてみてください。それは働いています...

ドキュメントの完全なイベント処理がわかります。

説明を参照してください。

static void Main() 
    { 

     //DECLARE INTERNET EXPLORER OBJECT 
     SHDocVw.InternetExplorer m_autologinIEWindow = new SHDocVw.InternetExplorer(); 

     //ASSOCIATE HANDLER TO DOCUMENT COMPLETE EVENT 
     m_autologinIEWindow.DocumentComplete += URLAutologinDocumentCompleteEventHandler; 

     //NAVIGATE THE URL 
     m_autologinIEWindow.Navigate("about:blank"); 
     m_autologinIEWindow.AddressBar = true; 
     m_autologinIEWindow.Visible = true; 

    } 

    //HANDLER DEFINITION 
    public static void URLAutologinDocumentCompleteEventHandler(object senderObject, ref object objectTwo /* not sure what this argument is for */) 
    { 
     //Something 
    } 
関連する問題