MACRO LIBRARY

Simple PropertyManager page example

Free public access. No account or subscription required.

Files

Simple PropertyManager page example

Code

Modules: main

'Written by Keith Rice
'CADSharp LLC
'www.cadsharp.com
    
'This macro is a basic example of creating a PropertyManager Page using the API.
    
'Make sure that the "SolidWorks 2011 exposed type libraries for add-in use" reference _
    is turned on. Next, create two classes---one for the property manager page and _
    one for the property manager handler, which handles events within the PMP. In your _
    main module, instantiate a new variable for the page class. In the handler class, _
    using Implements with PropertyManagerPage2Handler8 to derive the base (abstract) _
    class and then add every available procedure for that base class to the handler _
    class. In the layout class, create a sub procedure called Show that will create the _
    PMP using ISldWorks::CreatePropertyManagerPage. You will need to instantiate a _
    variable for the handler class and use it as one of the arguments in this method. _
    Include any event-triggered code in the handler class and any utility code in a _
    separate utilities class. Also note that a PMP can be created without a document _
    open but not displayed. Also note that the classes may need to have Public instancing _
    turned on.
    
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim pmPage As clsPMP
    
Sub main()
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set pmPage = New clsPMP
    pmPage.Show swApp
End Sub

Class Modules: clsPMP

Dim pmHandler As clsPMPHandler
Dim pmPage As SldWorks.PropertyManagerPage2
Dim pmGroup As SldWorks.PropertyManagerPageGroup
Dim pmLabel As SldWorks.PropertyManagerPageLabel
Dim lngErrors As Long
    
Sub Show(swApp As SldWorks.SldWorks)
    Set pmHandler = New clsPMPHandler
    Set pmPage = swApp.CreatePropertyManagerPage("Custom PMP", 1 + 2 + 4, pmHandler, lngErrors)
    If lngErrors = 0 Then
        pmPage.SetMessage3 "Hello world!", swImportantMessageBox, swMessageBoxMaintainExpandState, _
            "Important message"
        Set pmGroup = pmPage.AddGroupBox(0, "First group", swGroupBoxOptions_Expanded + _
            swGroupBoxOptions_Visible)
        Set pmLabel = pmGroup.AddControl(1, swControlType_Label, "First label", _
            swControlAlign_LeftEdge, swControlOptions_Visible + swControlOptions_Enabled, "A tip")
        pmPage.Show2 0
    Else
        Debug.Print "Error displaying PropertyManager page."
    End If
End Sub

Class Modules: clsPMPHandler

Implements PropertyManagerPage2Handler8
    
Private Sub PropertyManagerPage2Handler8_AfterActivation()
    MsgBox "Opening", vbMsgBoxSetForeground
End Sub
    
Private Sub PropertyManagerPage2Handler8_AfterClose()
    MsgBox "Closed", vbMsgBoxSetForeground
End Sub
    
Private Function PropertyManagerPage2Handler8_OnActiveXControlCreated(ByVal Id As Long, ByVal Status As Boolean) As Long
    
End Function
    
Private Sub PropertyManagerPage2Handler8_OnButtonPress(ByVal Id As Long)
    
End Sub
    
Private Sub PropertyManagerPage2Handler8_OnCheckboxCheck(ByVal Id As Long, ByVal Checked As Boolean)
    
End Sub
    
Private Sub PropertyManagerPage2Handler8_OnClose(ByVal Reason As Long)
    If Reason = swPropertyManagerPageClose_Okay Then
        MsgBox "OK: Closing", vbMsgBoxSetForeground
    Else
        MsgBox "Cancel: Closing", vbMsgBoxSetForeground
    End If
End Sub
    
Private Sub PropertyManagerPage2Handler8_OnComboboxEditChanged(ByVal Id As Long, ByVal Text As String)
    
End Sub
    
Private Sub PropertyManagerPage2Handler8_OnComboboxSelectionChanged(ByVal Id As Long, ByVal Item As Long)
    
End Sub
    
Private Sub PropertyManagerPage2Handler8_OnGainedFocus(ByVal Id As Long)
    
End Sub
    
Private Sub PropertyManagerPage2Handler8_OnGroupCheck(ByVal Id As Long, ByVal Checked As Boolean)
    
End Sub
    
Private Sub PropertyManagerPage2Handler8_OnGroupExpand(ByVal Id As Long, ByVal Expanded As Boolean)
    
End Sub
    
Private Function PropertyManagerPage2Handler8_OnHelp() As Boolean
    
End Function
    
Private Function PropertyManagerPage2Handler8_OnKeystroke(ByVal Wparam As Long, ByVal Message As Long, ByVal Lparam As Long, ByVal Id As Long) As Boolean
    
End Function
    
Private Sub PropertyManagerPage2Handler8_OnListboxRMBUp(ByVal Id As Long, ByVal PosX As Long, ByVal PosY As Long)
    
End Sub
    
Private Sub PropertyManagerPage2Handler8_OnListboxSelectionChanged(ByVal Id As Long, ByVal Item As Long)
    
End Sub
    
Private Sub PropertyManagerPage2Handler8_OnLostFocus(ByVal Id As Long)
    
End Sub
    
Private Function PropertyManagerPage2Handler8_OnNextPage() As Boolean
    
End Function
    
Private Sub PropertyManagerPage2Handler8_OnNumberboxChanged(ByVal Id As Long, ByVal Value As Double)
    
End Sub
    
Private Sub PropertyManagerPage2Handler8_OnOptionCheck(ByVal Id As Long)
    
End Sub
    
Private Sub PropertyManagerPage2Handler8_OnPopupMenuItem(ByVal Id As Long)
    
End Sub
    
Private Sub PropertyManagerPage2Handler8_OnPopupMenuItemUpdate(ByVal Id As Long, retval As Long)
    
End Sub
    
Private Function PropertyManagerPage2Handler8_OnPreview() As Boolean
    
End Function
    
Private Function PropertyManagerPage2Handler8_OnPreviousPage() As Boolean
    
End Function
    
Private Sub PropertyManagerPage2Handler8_OnRedo()
    
End Sub
    
Private Sub PropertyManagerPage2Handler8_OnSelectionboxCalloutCreated(ByVal Id As Long)
    
End Sub
    
Private Sub PropertyManagerPage2Handler8_OnSelectionboxCalloutDestroyed(ByVal Id As Long)
    
End Sub
    
Private Sub PropertyManagerPage2Handler8_OnSelectionboxFocusChanged(ByVal Id As Long)
    
End Sub
    
Private Sub PropertyManagerPage2Handler8_OnSelectionboxListChanged(ByVal Id As Long, ByVal Count As Long)
    
End Sub
    
Private Sub PropertyManagerPage2Handler8_OnSliderPositionChanged(ByVal Id As Long, ByVal Value As Double)
    
End Sub
    
Private Sub PropertyManagerPage2Handler8_OnSliderTrackingCompleted(ByVal Id As Long, ByVal Value As Double)
    
End Sub
    
Private Function PropertyManagerPage2Handler8_OnSubmitSelection(ByVal Id As Long, ByVal Selection As Object, ByVal SelType As Long, ItemText As String) As Boolean
    
End Function
    
Private Function PropertyManagerPage2Handler8_OnTabClicked(ByVal Id As Long) As Boolean
    
End Function
    
Private Sub PropertyManagerPage2Handler8_OnTextboxChanged(ByVal Id As Long, ByVal Text As String)
    
End Sub
    
Private Sub PropertyManagerPage2Handler8_OnUndo()
    
End Sub
    
Private Sub PropertyManagerPage2Handler8_OnWhatsNew()
    
End Sub
    
Private Function PropertyManagerPage2Handler8_OnWindowFromHandleControlCreated(ByVal Id As Long, ByVal Status As Boolean) As Long
    
End Function