几何尺寸与公差论坛

 找回密码
 注册
查看: 1152|回复: 0

【转帖】how to create activex control in vb.net for use in tab via addcontrol3

[复制链接]
发表于 2009-4-12 21:14:32 | 显示全部楼层 |阅读模式
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
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2024-12-23 14:06 , Processed in 0.036018 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表