MFC Activex OCX Javascript 互相訪問問題,線程回調javascript

來源:互聯網
上載者:User
//比較好的教程  ocx 在 win7 系統會出現註冊需要管理員權限的問題,這時候需要用管理員身份運行 cmd,然後運行 regsvr32註冊。 很麻煩 嘗試使用 nsis 做成安裝包, 採用 regdll 註冊 ocx, 成功。  

ocx和外面的程式互動主要通過提供方法屬性 + 事件

方法屬性可以提供給js調用,事件可以給js 通過下面的方式進行回調注入<object id="xxx"></object><script language="JavaScript" for="xx" Event="eventFunction(x)"> alert(x);</script>  或者document.getElementByIdx_x(xx).attachEvent("eventFunction",function(x,y){
alert(x);
});這兩種功能都可以在類別檢視裡面選擇  XXXCtrl,右鍵選擇 add ,會出現 方法屬性事件按照wizard進行添加就好。主要記錄一下如果ocx建立了線程,想通過事件回調js的話,會出現問題。這時候解決方案就是通過 PostMessage(WM_THREADFIREEVENT,(WPARAM)NULL,(LPARAM)NULL); 下面的看看應該懂了//------------------------- SAMPLE:   Firing   Events   From   a   Second   Thread   
    
  ---------------------------------------------------------------------   
  The   information   in   this   article   applies   to:   
    
    -   Microsoft   Visual   C++,   32-bit   Edition   versions   4.0,   4.1,   4.2   
  ---------------------------------------------------------------------   
    
  SUMMARY   
  =======   
    
  MFC   based   ActiveX   controls   typically   fire   their   events   from   the   same   thread   
  that   implements   the   sink   interface   of   the   container   that   the   events   are     
  being   fired   to.   
    
  Sometimes,   it   is   desirable   to   start   a   second   thread   in   an   ActiveX   control   
  which   will   fire   events   to   the   container.   Since   MFC   ActiveX   controls   
  use   the   Apartment   threading   model,   special   consideration   must   be   taken   
  into   account   when   firing   events   from   a   secondary   thread.   
  

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.