控件中的自定义事件说明 得到事件参数,调用控件的CustomEventParam 设置事件返回数据,调用控件的Mx_SetEventRetEx
interface MxDrawXCustomEvent;
MxDrawXCustomFunction.idl
例如: C#下面的使用例子
private void axMxDrawX1_CustomEvent(object sender, AxMxDrawXLib._DMxDrawXEvents_CustomEventEvent e) { System.String sTmp; if (e.sEventName == "SetTipCoord") { MxDrawResbuf pParam = (MxDrawResbuf)(axMxDrawX1.CustomEventParam()); sTmp = pParam.AtString(0); } else if(e.sEventName == "SysVarChanged") { // 系统变量发生改事件. MxDrawResbuf pParam = (MxDrawResbuf)(axMxDrawX1.CustomEventParam()); // 得到系统变量名. System.String sVarName = pParam.AtString(0); if (sVarName == "ORTHOMODE") { // 垂直输入变量发生改变,得到改变后的值. MxDrawResbuf spVarValue = (MxDrawResbuf)(axMxDrawX1.Call("GetSysVar", sVarName)); Int32 iOsmode = spVarValue.AtLong(1); MxDrawUtility mxUtility = new MxDrawUtility(); mxUtility.Prompt("n" + sVarName + "值:" + iOsmode); } } else if(e.sEventName == "OpenFileComplete") { // 打开图纸结束事件. // MessageBox.Show("OpenFileComplete"); } else if (e.sEventName == "MxDrawXInitComplete") { // 控件加载初始化完成. //MessageBox.Show("MxDrawXInitComplete"); } }
例如:JS下响应事件的代码
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <titleMxDraw控件</title> </head> <SCRIPT language="JavaScript"> document.oncontextmenu = new Function('event.returnValue=false;'); //禁用右键 </SCRIPT> <body topmargin="10" leftmargin="10"> align="center"<object classid="clsid:74A777F8-7A8F-4e7c-AF47-7074828086E2" id="MxDrawXCtrl1" width=50% height=90% align="left"> </object> <script> function CustomEvent(sEventName) { if(sEventName == "Mx_UpdateDisplay") { // 视区更新 // alert("Mx_UpdateDisplay"); var eventParam = document.getElementById("MxDrawXCtrl1").CustomEventParam(); if(eventParam.AtLong(0) == 1) { alert("更新显示缓存"); } } } document.getElementById("MxDrawXCtrl1").ImplementCustomEvent = CustomEvent; </script> </p> </body> </html>