Hide Table of Contents

Add ActiveX Tab to FeatureManager Design Tree Example (VBA)

This example shows how to add a tab to the FeatureManager design tree using three on-disk bitmap files for the tab's scaleable icon.

'----------------------------------------------------------
' Preconditions:
' 1. In the IDE, reference the ActiveX control file
'    a. Click Tools > References > Browse.
'    b. Browse to c:\Program Files\SOLIDWORKS Corp\SOLIDWORKS\SldUtils.
'    c. Select RichEditCtrl.ocx.
'    d. Click Open.
'    e. Click OK.
' 2. Insert the ActiveX component
'    Click Insert > Components > RichEditCtrl ActiveX Control module > OK.
' 3. Verify that the specified part document exists.
' 4. Modify the paths in bitmapnames to reference your tab icon's bitmap files in three sizes.
' 5. Review the ActiveX control reference and ensure that the ctrlBtm declaration is correct.
' 6. Search for RichEditCtrl.ocx in the registry and ensure that the second
'    argument of the CreateFeatureMgrControl4 call is correct.
'
' Postconditions:
' 1. Opens the part document and adds a new tab
'    to the FeatureManager design tree with an icon that uses the bitmap size that
'    fits the screen resolution.
'    NOTE: To add a tab to the FeatureManager tree,
'    you must set IModelViewManager::CreateFeatureMgrControl4's
'    WhichPane parameter to swFeatMgrPane_e.swFeatMgrPaneBottom.
' 2. Activates the new tab and displays the ActiveX control.
'
' NOTE: Because the part document is used elsewhere,
' do not save changes.
'----------------------------------------------------------
Option Explicit
Sub main()
     
    Dim swApp As SldWorks.SldWorks
    Dim swModel As SldWorks.ModelDoc2
    Dim swModViewMgr As SldWorks.ModelViewManager
    Dim swFeatMgrTabBtm As SldWorks.FeatMgrView
    Dim ctrlBtm As RICHEDITCTRLLib.RichEditCtrl
    Dim fileName As String
    Dim errors As Long
    Dim warnings As Long
    Dim activePane As Long
    Dim bitmapnames(2) As String
     Set swApp = CreateObject("SldWorks.Application")
    fileName = "C:\Users\Public\Documents\SOLIDWORKS\SOLIDWORKS 2020\samples\tutorial\fillets\knob.sldprt"
    Set swModel = swApp.OpenDoc6(fileName, swDocPART, swOpenDocOptions_Silent, "", errors, warnings)
    Set swModViewMgr = swModel.ModelViewManager
    
    bitmapnames(0) = "C:\Users\J4M\Desktop\icons\mainicon_20.png"
    bitmapnames(1) = "C:\Users\J4M\Desktop\icons\mainicon_32.png"
    bitmapnames(2) = "C:\Users\J4M\Desktop\icons\mainicon_40.png"
    ' Create and activate the new tab
    Set swFeatMgrTabBtm = swModViewMgr.CreateFeatureMgrControl4(bitmapnames, "GTSWRICHEDITCTRL.RichEditCtrlCtrl.1", "", "Tab ToolTip", swFeatMgrPaneBottom)
    Set ctrlBtm = swFeatMgrTabBtm.GetControl
    activePane = swFeatMgrTabBtm.ActivateView
End Sub


Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Add ActiveX Tab to FeatureManager Design Tree Example (VBA)
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:

x

We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again
x

Web Help Content Version: API Help (English only) 2024 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.