几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » SolidWorks二次开发
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


回复
 
主题工具 搜索本主题 显示模式
旧 2009-04-12, 09:14 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】how to create activex control in vb.net for use in tab via addcontrol3

how to create activex control in vb.net for use in tab via addcontrol3
i am trying to create a custom tab in the model view of sw with vb.net. this appears to be done via the swmodelviewmgr.addcontrol3 method which requires an activex control. so the next step was to design an activex control in vb.net that contained the data and controls i want on my tab.
after much searching i found the microsoft interop forms toolkit 2.0 which provides a useful template for easily creating an old style activex control in vb.net that can properly run under vb 6.0 and anything else that runs pre- .net activex controls. my test activex control loads fine and functions properly in microsoft access and vb 6.0, but when i attempt to create it in sw by passing its name or class id into the addcontrol3 method, it always fails (the returned object is nothing). if i try an activex control like the microsoft calendar passing in "mscal.calendar" to addcontrol3 it successfully creates the tab with the calendar on it. so there is apparently something missing in my activex control that mscal.calendar has which keeps it from loading properly in sw.
does anyone know what is missing or know how to build an activex control properly in vb.net that can be successfully loaded via addcontrol3. is there a completely different way to add your own custom tab to the model view besides addcontrol3 that i have overlooked? any help or suggestions would be greatly appreciated!
regards,
dave blackburn
cad fx, inc.
dave,
check if you have registered your control.
if using vb use "regsvr32.exe" to register your control.
--vinayak
yes, it's registered and appears in the list of available activex controls to use within microsoft access and vb 6.0. and it works fine in those applications, so i don't think that is the problem.
even i tried developing control in vb.net & then using in swaddin(c++) but i couldn't .
then i developed the same control in vb6.0 & used in swaddin. it worked.
--vinayak
edited: 06/08/2007 at 08:34 am by vinayak singh
f.y.i. if you are attempting to add your own tab in .net as i've described, i found a sloppy work around, but also an apparent bug.
the work around is to create an activex control in vb 6.0. then on this control you can reference your vb .net created activex control. solidworks has no problem creating a tab with an activex control created in this way. obviously, this is not ideal so if anyone knows the answer to what is required in a vb .net activex to allow it to be used in the swmodelviewmgr.addcontrol3 function successfully, i would still like to know.
this also brings me to the apparent bug with the addcontrol3 function. if i create a tab using this function, solidworks does not properly close. it appears to close, but a check of the processes in task manager shows that it is not closed. this can be tested by creating an add-in in vb.net using the solidworks add-in template and adding the following 3 lines to the sldworks_documentloadnotify function:
dim doc as modeldoc2 = iswapp.activedoc
dim swmodelviewmgr as sldworks.modelviewmanager = doc.modelviewmanager
swmodelviewmgr.addcontrol3("my calendar tab", "mscal.calendar", "", false)
this will add a "my calendar tab" to the assembly model view with a microsoft calendar on it. however, when you close solidworks, if you check the task manager you will see it does not completely shut down. calling the swmodelviewmgr.deletecontroltab function does not solve the problem either. (i'm running sw 2007 sp 3.0.)
i have tried calling deletecontroltab which is a requirement for every tab created by addcontrol3, but still have the problem. perhaps i'm not calling it at the correct time or something. utilizing addcontrol solves this problem, but does not provide the tab traversal support that addcontrol3 does if that is needed.
dave blackburn
edited: 06/19/2007 at 11:14 am by david blackburn
answer i heard back from solidworks support on this with a solution, so here it is...
simply create a user control in vb.net or c#. then add the following attribute to your user control class:
<licenseproviderattribute(gettype(licfilelicenseprovider))>
this requires the following import:
imports system.componentmodel
ensure that you have the "register for com interop" turned on and that should be all you need to do. compiling your add-in will also create the necessary registry settings for your new com control whose class name or classid can be used in a call to modelviewmanager.addcontrol3 which will create a tab with your user control on it.
thanks to frank lindeman of api support for this answer!
edited: 06/19/2007 at 11:07 am by david blackburn
quick
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭



所有的时间均为北京时间。 现在的时间是 07:52 PM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多