aardio 文档
aardio 范例: 清单免注册嵌入 VB 控件
com.actCtx 更简单
//清单免注册
//com.actCtx 更简单: https://www.aardio.com/zh-cn/docs/examples/COM/RegFree/com.actCtx.html
import fonts.fontAwesome;
import win.ui;
/*DSG{{*/
var winform = win.form(text="清单免注册嵌入 VB 控件";right=700;bottom=266)
winform.add(
edit={cls="edit";left=356;top=20;right=665;bottom=243;anchors={left=1;top=1;right=1;bottom=1};edge=1;hscroll=1;multiline=1;vscroll=1;z=2};
static={cls="static";text="Static";left=21;top=20;right=330;bottom=243;anchors={left=1;top=1};transparent=1;z=1}
)
/*}}*/
import raw.activationContext;
var actCtx = raw.activationContext();
actCtx.source = "~\examples\Languages\VB\.vb6\Vb6Control.manifest"
import com.actCtx;
//VB6 重新编译控件时 CLSID 可能会变,所以用下面的函数自动生成。
com.actCtx.createDefaultManifest("~\examples\Languages\VB\.vb6\Vb6Control.ocx",actCtx.source);
//免注册嵌入控件对象
actCtx.activate();//激活清单上下文
var vbCtrl = winform.static.createEmbedEx( "{3BFE02F8-037B-4893-9573-B9DF4435AAB9}" );
actCtx.deactivate();//取消激活清单上下文
//响应 COM 事件
vbCtrl.OnImageClick = function(value){
winform.edit.print("VB控件里点击了图像,事件参数:"+value)
return 100; //VB里这个事件的参数声明为 ByRef,所以添加返回值可以修改参数
}
//修改 VB 控件的属性
vbCtrl.Picture = com.picture.loadObject( "~\examples\Graphics\.gdip.jpg" )
//调用 VB 控件的函数
var c = vbCtrl.Add(2,3);
winform.edit.print("调用 VB 控件函数返回值:",c);
winform.edit.print("请点击图像试试");
winform.show();
win.loopMessage();
Markdown 格式