!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
//........................................................................
};