Hide Table of Contents

Set Focus on PropertyManager Page Control Example (VBA)

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 swpublished.tlb (click

'     Tools > References > SolidWorks version exposed type libraries

'     for add-in use).

'  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 printed to Immediate window.

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

'     Verification printed to Immediate window.

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

' Module - Main

Option Explicit

 

Public swApp As SldWorks.SldWorks

Public Part As SldWorks.ModelDoc2

Public pm As clsPropMgr

 

Sub main()

 

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc

 

'Create a new instance of the PropertyManager class

Set pm = New clsPropMgr

pm.Show

End Sub

 

Back to top

' Class Modules - clsPropMgr

Option Explicit

 

'Required for PropertyManager page controls

Implements PropertyManagerPage2Handler7

 

'General objects required for the PropertyManager page

Dim pm_Page As PropertyManagerPage2

Dim pm_Checkbox As PropertyManagerPageCheckbox

Dim pm_Text As PropertyManagerPageTextbox

Dim pm_Group As PropertyManagerPageGroup

 

'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

Private Sub Class_Initialize()

 

Dim PageTitle As String

Dim options As Long

Dim errors As Long

Dim caption As String

Dim alignment As Long

Dim control As Long

 

'Set the variables for the page

PageTitle = "Test focus methods"

options = swPropertyManager_OkayButton _

    + swPropertyManager_CancelButton _

    + swPropertyManagerOptions_LockedPage _

    + swPropertyManagerOptions_PushpinButton

 

'Create the PropertyManager page

Set pm_Page = swApp.CreatePropertyManagerPage(PageTitle, _

    options, Me, errors)

 

'Make sure that the page was created properly

If errors = swPropertyManagerPage_Okay Then

    ' Create the group box

    caption = "Group box"

    options = swGroupBoxOptions_Visible + _

        swGroupBoxOptions_Expanded

    Set 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 = swControlType_Checkbox

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

    pm_Checkbox.Checked = False

 

    ' Create text box

    control = swControlType_Textbox

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

        

Else  'If the page is not created

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

        & "PropertyManager Page", vbCritical

End If

 

End Sub

 

Private Sub PropertyManagerPage2Handler7_AfterActivation()

End Sub

Private Sub PropertyManagerPage2Handler7_AfterClose()

    'Destroy the class

    Set pm = Nothing

End Sub

Private Function PropertyManagerPage2Handler7_OnActiveXControlCreated(ByVal Id As Long, ByVal Status As Boolean) As Long

End Function

Private Sub PropertyManagerPage2Handler7_OnButtonPress(ByVal Id As Long)

End Sub

Private Sub PropertyManagerPage2Handler7_OnCheckboxCheck(ByVal Id As Long, ByVal Checked As Boolean)

    ' 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

Private Sub PropertyManagerPage2Handler7_OnClose(ByVal Reason As Long)

If Reason = swPropertyManagerPageClose_Cancel Then

    'Cancel button was clicked

    ClickedCancel = True

ElseIf Reason = swPropertyManagerPageClose_Okay Then

    'OK button was clicked

    ClickedCancel = False

End If

End Sub

Private Sub PropertyManagerPage2Handler7_OnComboboxEditChanged(ByVal Id As Long, ByVal Text As String)

End Sub

Private Sub PropertyManagerPage2Handler7_OnComboboxSelectionChanged(ByVal Id As Long, ByVal Item As Long)

End Sub

Private Sub PropertyManagerPage2Handler7_OnGroupCheck(ByVal Id As Long, ByVal Checked As Boolean)

End Sub

Private Sub PropertyManagerPage2Handler7_OnGroupExpand(ByVal Id As Long, ByVal Expanded As Boolean)

End Sub

Private Function PropertyManagerPage2Handler7_OnHelp() As Boolean

End Function

Private Function PropertyManagerPage2Handler7_OnKeystroke(ByVal Wparam As Long, ByVal Message As Long, ByVal Lparam As Long, ByVal Id As Long) As Boolean

End Function

Private Sub PropertyManagerPage2Handler7_OnListboxSelectionChanged(ByVal Id As Long, ByVal Item As Long)

End Sub

Private Function PropertyManagerPage2Handler7_OnNextPage() As Boolean

End Function

Private Sub PropertyManagerPage2Handler7_OnNumberboxChanged(ByVal Id As Long, ByVal Value As Double)

End Sub

Private Sub PropertyManagerPage2Handler7_OnOptionCheck(ByVal Id As Long)

End Sub

Private Sub PropertyManagerPage2Handler7_OnPopupMenuItem(ByVal Id As Long)

End Sub

Private Sub PropertyManagerPage2Handler7_OnPopupMenuItemUpdate(ByVal Id As Long, retVal As Long)

End Sub

Private Function PropertyManagerPage2Handler7_OnPreview() As Boolean

End Function

Private Function PropertyManagerPage2Handler7_OnPreviousPage() As Boolean

End Function

Private Sub PropertyManagerPage2Handler7_OnRedo()

End Sub

Private Sub PropertyManagerPage2Handler7_OnSelectionboxCalloutCreated(ByVal Id As Long)

End Sub

Private Sub PropertyManagerPage2Handler7_OnSelectionboxCalloutDestroyed(ByVal Id As Long)

End Sub

Private Sub PropertyManagerPage2Handler7_OnSelectionboxFocusChanged(ByVal Id As Long)

End Sub

Private Sub PropertyManagerPage2Handler7_OnSelectionboxListChanged(ByVal Id As Long, ByVal Count As Long)

End Sub

Private Sub PropertyManagerPage2Handler7_OnSliderPositionChanged(ByVal Id As Long, ByVal Value As Double)

End Sub

Private Sub PropertyManagerPage2Handler7_OnSliderTrackingCompleted(ByVal Id As Long, ByVal Value As Double)

End Sub

Private Function PropertyManagerPage2Handler7_OnSubmitSelection(ByVal Id As Long, ByVal Selection As Object, ByVal SelType As Long, ItemText As String) As Boolean

End Function

Private Function PropertyManagerPage2Handler7_OnTabClicked(ByVal Id As Long) As Boolean

End Function

Private Sub PropertyManagerPage2Handler7_OnTextboxChanged(ByVal Id As Long, ByVal Text As String)

End Sub

Private Sub PropertyManagerPage2Handler7_OnUndo()

End Sub

Private Sub PropertyManagerPage2Handler7_OnWhatsNew()

End Sub

Private Sub PropertyManagerPage2Handler7_OnLostFocus(ByVal Id As Long)

End Sub

Private Sub PropertyManagerPage2Handler7_OnGainedFocus(ByVal Id As Long)

End Sub

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 (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) 2010 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.