Hide Table of Contents

Set Focus on PropertyManager Page Control Example (VB.NET)

This example shows how to set focus on a PropertyManager page control.

'----------------------------------------------------------------------------

' Preconditions:

'  1. Open a model document.

'  2. Copy Module - Main to your project.

'  3. Copy Class Modules - clsPropMgr to a class module in your project.

'  4. Add a reference to the SolidWorks.Interop.swpublished primary interop

'     assembly (in the IDE, right-click the name of the project,

'     select Add Reference, and select SolidWorks.Interop.swpublished).

'  5. Open the Immediate window.

'  6. Run the macro.

'      

' Postconditions:

'  1. PropertyManager page is created and displayed.

'  2. Select the checkbox to set focus on Text box.

'     Verification is printed to the Immediate window.

'  3. Deselect the checkbox to remove focus from Text box.

'     Verification is printed to the Immediate window.

'----------------------------------------------------------------------------

 

' Module - Main

Imports SolidWorks.Interop.sldworks

Imports SolidWorks.Interop.swconst

Imports System

Partial Class SolidWorksMacro

    Public Part As ModelDoc2

    Public WithEvents pm As clsPropMgr

    Sub main()

 

        swApp.SetUserPreferenceToggle(swUserPreferenceToggle_e.swStopDebuggingVstaOnExit, False)

        Part = swApp.ActiveDoc

 

        'Create a new instance of the PropertyManager class

        pm = New clsPropMgr(swApp)

        pm.Show()

 

    End Sub

 

    Public swApp As SldWorks

 

End Class

Back to top

' Class Modules - clsPropMgr

 

Imports SolidWorks.Interop.sldworks

Imports SolidWorks.Interop.swconst

Imports SolidWorks.Interop.swpublished

Imports System

Imports System.Runtime.InteropServices

Imports System.Diagnostics

 

<ComVisibleAttribute(True)> _

Public Class clsPropMgr

 

    Implements PropertyManagerPage2Handler7

 

    Dim swApp As SldWorks

 

    'General objects required for the PropertyManager page

    Dim pm_Page As PropertyManagerPage2

    Dim pm_Group As PropertyManagerPageGroup

    Dim pm_Checkbox As PropertyManagerPageCheckbox

    Dim pm_Text As PropertyManagerPageTextbox

 

    'Each object in the page needs a unique ID

    Const checkboxID As Integer = 1

    Const textID As Integer = 2

    Const groupID As Integer = 3

    Dim ClickedCancel As Boolean

 

    Sub Show()

        pm_Page.Show2(0)

    End Sub

 

    'The following runs when a new instance

    'of the class is created

    Public Sub New(ByVal swApp As SldWorks)

 

        Dim PageTitle As String

        Dim options As Integer

        Dim errors As Integer

        Dim caption As String

        Dim alignment As Integer

        Dim control As Integer

 

        'Set the variables for the page

        PageTitle = "Test focus methods"

        options = swPropertyManagerButtonTypes_e.swPropertyManager_OkayButton _

            + swPropertyManagerButtonTypes_e.swPropertyManager_CancelButton _

            + swPropertyManagerPageOptions_e.swPropertyManagerOptions_LockedPage _

            + swPropertyManagerPageOptions_e.swPropertyManagerOptions_PushpinButton

 

        'Create the PropertyManager page

        pm_Page = CType(swApp.CreatePropertyManagerPage(PageTitle, _

            options, Me, errors), PropertyManagerPage2)

 

        'Make sure that the page was created properly

        If errors = swPropertyManagerPageStatus_e.swPropertyManagerPage_Okay Then

 

            'Begin adding the controls to the page

            ' Create the group box

            caption = "Group box"

            options = swAddGroupBoxOptions_e.swGroupBoxOptions_Visible + _

                swAddGroupBoxOptions_e.swGroupBoxOptions_Expanded

            pm_Group = pm_Page.AddGroupBox(groupID, caption, options)

 

            ' Create checkbox

            alignment = swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge

            options = swAddControlOptions_e.swControlOptions_Visible + _

                swAddControlOptions_e.swControlOptions_Enabled

            control = swPropertyManagerPageControlType_e.swControlType_Checkbox

            pm_Checkbox = pm_Group.AddControl(checkboxID, control, "Focus on text box", alignment, options, "Checkbox")

            pm_Checkbox.Checked = False

 

            ' Create text box

            control = swPropertyManagerPageControlType_e.swControlType_Textbox

            pm_Text = pm_Group.AddControl(textID, control, "Text box", alignment, options, "Text box")

        Else  'If the page is not created

            MsgBox("An error while attempting to create the " _

                & "PropertyManager Page", vbCritical)

        End If

 

    End Sub

 

    Public Sub AfterActivation() Implements SolidWorks.Interop.swpublished.IPropertyManagerPage2Handler7.AfterActivation

    End Sub

    Public Sub AfterClose() Implements SolidWorks.Interop.swpublished.IPropertyManagerPage2Handler7.AfterClose

    End Sub

    Public Function OnActiveXControlCreated(ByVal Id As Integer, ByVal Status As Boolean) As Integer Implements SolidWorks.Interop.swpublished.IPropertyManagerPage2Handler7.OnActiveXControlCreated

    End Function

    Public Sub OnButtonPress(ByVal Id As Integer) Implements SolidWorks.Interop.swpublished.IPropertyManagerPage2Handler7.OnButtonPress

    End Sub

    Public Sub OnCheckboxCheck(ByVal Id As Integer, ByVal Checked As Boolean) Implements SolidWorks.Interop.swpublished.IPropertyManagerPage2Handler7.OnCheckboxCheck

        ' Set focus on the text box when check box is selected

        If Checked Then

            pm_Page.SetFocus(textID)

            Debug.Print("Focus on Text box.")

        Else

            Debug.Print("Focus off Text box.")

        End If

    End Sub

    Public Sub OnClose(ByVal Reason As Integer) Implements SolidWorks.Interop.swpublished.IPropertyManagerPage2Handler7.OnClose

        If Reason = swPropertyManagerPageCloseReasons_e.swPropertyManagerPageClose_Cancel Then

            ' Cancel button was clicked

            ClickedCancel = True

        ElseIf Reason = swPropertyManagerPageCloseReasons_e.swPropertyManagerPageClose_Okay Then

            ' OK button was clicked

            ClickedCancel = False

        End If

    End Sub

    Public Sub OnComboboxEditChanged(ByVal Id As Integer, ByVal Text As String) Implements SolidWorks.Interop.swpublished.IPropertyManagerPage2Handler7.OnComboboxEditChanged

    End Sub

    Public Sub OnComboboxSelectionChanged(ByVal Id As Integer, ByVal Item As Integer) Implements SolidWorks.Interop.swpublished.IPropertyManagerPage2Handler7.OnComboboxSelectionChanged

    End Sub

    Public Sub OnGainedFocus(ByVal Id As Integer) Implements SolidWorks.Interop.swpublished.IPropertyManagerPage2Handler7.OnGainedFocus

    End Sub

    Public Sub OnGroupCheck(ByVal Id As Integer, ByVal Checked As Boolean) Implements SolidWorks.Interop.swpublished.IPropertyManagerPage2Handler7.OnGroupCheck

    End Sub

    Public Sub OnGroupExpand(ByVal Id As Integer, ByVal Expanded As Boolean) Implements SolidWorks.Interop.swpublished.IPropertyManagerPage2Handler7.OnGroupExpand

    End Sub

    Public Function OnHelp() As Boolean Implements SolidWorks.Interop.swpublished.IPropertyManagerPage2Handler7.OnHelp

    End Function

    Public Function OnKeystroke(ByVal Wparam As Integer, ByVal Message As Integer, ByVal Lparam As Integer, ByVal Id As Integer) As Boolean Implements SolidWorks.Interop.swpublished.IPropertyManagerPage2Handler7.OnKeystroke

    End Function

    Public Sub OnListboxSelectionChanged(ByVal Id As Integer, ByVal Item As Integer) Implements SolidWorks.Interop.swpublished.IPropertyManagerPage2Handler7.OnListboxSelectionChanged

    End Sub

    Public Sub OnLostFocus(ByVal Id As Integer) Implements SolidWorks.Interop.swpublished.IPropertyManagerPage2Handler7.OnLostFocus

    End Sub

    Public Function OnNextPage() As Boolean Implements SolidWorks.Interop.swpublished.IPropertyManagerPage2Handler7.OnNextPage

    End Function

    Public Sub OnNumberboxChanged(ByVal Id As Integer, ByVal Value As Double) Implements SolidWorks.Interop.swpublished.IPropertyManagerPage2Handler7.OnNumberboxChanged

    End Sub

    Public Sub OnOptionCheck(ByVal Id As Integer) Implements SolidWorks.Interop.swpublished.IPropertyManagerPage2Handler7.OnOptionCheck

    End Sub

    Public Sub OnPopupMenuItem(ByVal Id As Integer) Implements SolidWorks.Interop.swpublished.IPropertyManagerPage2Handler7.OnPopupMenuItem

    End Sub

    Public Sub OnPopupMenuItemUpdate(ByVal Id As Integer, ByRef retval As Integer) Implements SolidWorks.Interop.swpublished.IPropertyManagerPage2Handler7.OnPopupMenuItemUpdate

    End Sub

    Public Function OnPreview() As Boolean Implements SolidWorks.Interop.swpublished.IPropertyManagerPage2Handler7.OnPreview

    End Function

    Public Function OnPreviousPage() As Boolean Implements SolidWorks.Interop.swpublished.IPropertyManagerPage2Handler7.OnPreviousPage

    End Function

    Public Sub OnRedo() Implements SolidWorks.Interop.swpublished.IPropertyManagerPage2Handler7.OnRedo

    End Sub

    Public Sub OnSelectionboxCalloutCreated(ByVal Id As Integer) Implements SolidWorks.Interop.swpublished.IPropertyManagerPage2Handler7.OnSelectionboxCalloutCreated

    End Sub

    Public Sub OnSelectionboxCalloutDestroyed(ByVal Id As Integer) Implements SolidWorks.Interop.swpublished.IPropertyManagerPage2Handler7.OnSelectionboxCalloutDestroyed

    End Sub

    Public Sub OnSelectionboxFocusChanged(ByVal Id As Integer) Implements SolidWorks.Interop.swpublished.IPropertyManagerPage2Handler7.OnSelectionboxFocusChanged

    End Sub

    Public Sub OnSelectionboxListChanged(ByVal Id As Integer, ByVal Count As Integer) Implements SolidWorks.Interop.swpublished.IPropertyManagerPage2Handler7.OnSelectionboxListChanged

    End Sub

    Public Sub OnSliderPositionChanged(ByVal Id As Integer, ByVal Value As Double) Implements SolidWorks.Interop.swpublished.IPropertyManagerPage2Handler7.OnSliderPositionChanged

    End Sub

    Public Sub OnSliderTrackingCompleted(ByVal Id As Integer, ByVal Value As Double) Implements SolidWorks.Interop.swpublished.IPropertyManagerPage2Handler7.OnSliderTrackingCompleted

    End Sub

    Public Function OnSubmitSelection(ByVal Id As Integer, ByVal Selection As Object, ByVal SelType As Integer, ByRef ItemText As String) As Boolean Implements SolidWorks.Interop.swpublished.IPropertyManagerPage2Handler7.OnSubmitSelection

    End Function

    Public Function OnTabClicked(ByVal Id As Integer) As Boolean Implements SolidWorks.Interop.swpublished.IPropertyManagerPage2Handler7.OnTabClicked

    End Function

    Public Sub OnTextboxChanged(ByVal Id As Integer, ByVal Text As String) Implements SolidWorks.Interop.swpublished.IPropertyManagerPage2Handler7.OnTextboxChanged

    End Sub

    Public Sub OnUndo() Implements SolidWorks.Interop.swpublished.IPropertyManagerPage2Handler7.OnUndo

    End Sub

    Public Sub OnWhatsNew() Implements SolidWorks.Interop.swpublished.IPropertyManagerPage2Handler7.OnWhatsNew

    End Sub

End Class

Back to top

 



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:   Set Focus on PropertyManager Page Control Example (VB.NET)
*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) 2016 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.