想用VC2012封裝一個ocx,把對讀卡器的呼叫封裝在里面,給網頁呼叫。
誰能給一個封裝ocx和網頁呼叫的簡單代碼。或者給一個有用的鏈接。謝謝謝謝!
uj5u.com熱心網友回復:
VC2012用標準方法做一個ocx就可以了至于網頁中怎么呼叫ocx百度一大堆啊
uj5u.com熱心網友回復:
LONG CActiveXDemoCtrl::AddFun(LONG Add1, LONG Add2){
AFX_MANAGE_STATE(AfxGetStaticModuleState());
// TODO: 在此添加調度處理程式代碼
return Add1+Add2;
}
BSTR CActiveXDemoCtrl::HelloWord(void)
{
AFX_MANAGE_STATE(AfxGetAppModuleState());
CString strResult;
// TODO: 在此添加調度處理程式代碼
strResult = "Hello Word";
return strResult.AllocSysString();
}
按照標準方法寫了上面的代碼,ocx檔案生成了,也用regsvr32注冊成功了。但是網頁呼叫的時候,提示“SCRIPT438: 物件不支持“HelloWord”屬性或方法”
現在不知道怎么解決
uj5u.com熱心網友回復:
<html><head>
<!-- saved from url=(0017)http://localhost/ -->
<script type="text/javascript" language="javascript">
function show(){
var ocx = document.getElementById("TestOcx_new");
var a = TestOcx_new.HelloWord();
alert(a);
}
</script>
</head>
<object id="TestOcx_new" width="32" height="32"
classid="clsid:CFC032F2-57B0-4ADE-93AE-4877F6F3E5BD"
codebase="C:/Windows/SysWOW64/ActiveXDemo.ocx"
</object>
<body onload="show()">
var ocx = document.getElementById("TestOcx_new");
var a = TestOcx_new.HelloWord();
alert(a);
</body>
</html>
網頁的代碼是這樣寫的
uj5u.com熱心網友回復:
求指教求指教轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/68694.html
下一篇:如何判斷停車位上是否有車
