//比較好的教程
ocx 在 win7 系統會出現注冊需要管理員權限的問題,這時候需要用管理員身份運行 cmd,然后運行 regsvr32注冊。
很麻煩
嘗試使用 nsis 做成安裝包, 采用 regdll 注冊 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);
});
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.
