!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0027)http://www.chinaidcard.com/ -->
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>OCX測試頁</title>
</head>
<body style="text-align: center">
<form id="form1" runat="server">
<OBJECT classid="clsid:2CB714FA-FCDA-4040-AA09-C9F7B16A79BC" id="TestOCX" name="TestOCX" width="1px" height="1px" ></OBJECT>
<script language="javascript" type ="text/javascript">
function Button2_onclick() {
var TestOCX = document.getElementById("TestOCX");
TestOCX.AboutBox();
}
</script>TestOcx
</form>
<input id="Button3" type="button" value="關 於" onclick="return Button2_onclick()" />
</body>
</html>

注要事項:
1. ActiveX控件的類ID, 即coclass XXX上標注的UUID。
2.ActiveX控件在Google chrome上似乎運行有問題。
3.編譯ocx要注意32位IE與x64 IE
4.ocx讀寫文件時, 注意ie運行權限, 以及目標文件的位置。(在win7下,可以試試c:\\abc\\a.jpg)
---------------------
MFC ocx控件制作注意事項
1. windows7 需要sp1
2.OCX實現安全接口
#include <objsafe.h> // for IObjectSafety; in ActiveX SDK class CtryISafeObjectCtrl : public COleControl { DECLARE_DYNCREATE(CtryISafeObjectCtrl) //........................................................................ //ISafeObject DECLARE_INTERFACE_MAP() BEGIN_INTERFACE_PART(ObjSafe, IObjectSafety) STDMETHOD_(HRESULT, GetInterfaceSafetyOptions) ( /* [in] */ REFIID riid, /* [out] */ DWORD __RPC_FAR *pdwSupportedOptions, /* [out] */ DWORD __RPC_FAR *pdwEnabledOptions ); STDMETHOD_(HRESULT, SetInterfaceSafetyOptions) ( /* [in] */ REFIID riid, /* [in] */ DWORD dwOptionSetMask, /* [in] */ DWORD dwEnabledOptions ); END_INTERFACE_PART(ObjSafe); //ISafeObject //........................................................................ };
