Hide Table of Contents
OnClose Method (IPropertyManagerPage2Handler6)

Obsoleted. Superseded by IPropertyManagerPage2Handler7::OnClose.

.NET Syntax

Visual Basic (Declaration) 
Sub OnClose( _
   ByVal Reason As System.Integer _
Visual Basic (Usage) 
Dim instance As IPropertyManagerPage2Handler6
Dim Reason As System.Integer
void OnClose( 
   System.int Reason
void OnClose( 
&   System.int Reason



Reason this method is called as defined in swPropertyManagerPageCloseReasons_e


This handler method is called when the PropertyManager page is about to close.  


SolidWorks controls when add-ins can do work. An add-in is unable to do any real work within the PropertyManager2Handler6::OnClose handler because the PropertyManager page and command are closing. So, typically the IPropertyPage2Handler6::AfterClose handler is called after IPropertyManager2Handler6::OnClose to allow an add-in to do work. However:


If PropertyManager page is...

And you implemented the handler in...

Then you...

Not pinned


Can prevent the PropertyManager page from closing by setting the HRESULT return value to S_false.


Visual Basic

Should use the Err.Raise method with a value of 1 to prevent the PropertyManager page from closing. In VB.NET, use 0 with Err.Raise.


NOTE:  When control returns to SolidWorks:

  • The IPropertyManager page remains displayed on the screen.

  • The IPropertyManagerPage2Handler5::AfterClose handler is not called.


C++ or Visual Basic

Set HRESULT to S_false to close the PropertyManager page (i.e., ignore the fact that the page is pinned).

This allows your add-in to call the IPropertyManagerPage2Handler6::AfterClose handler and do its work. To avoid aggravating your user, who expected the PropertyManager page  to remain pinned, you should re-display and re-pin the PropertyManager page after the add-in finishes its work.


NOTE: In a previous version of this method, IPropertyManagerPage2Handler3::OnClose, if the user clicked the Cancel button and the PropertyManager page had a pushpin, then this method returned swPropertyManagerPageClose_Closed. This version of this method returns swPropertyManagerPageClose_Cancel in this scenario.


Managed code can indicate that a PropertyManager page cannot be closed. Throw a COM exception with an error code of 1. For example, in C#:
    void OnClose (int reason)
         // Throw a COM exception as an indication the PropertyManager
         // page cannot be closed at this time:
         // The error code must be 1, which equates to S_FALSE.
        COMException ex = new COMException("Cannot close PropertyManager page", 1);
        throw ex;


See Also


SolidWorks 2009 FCS, Revision Number 17.0

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

Subject:   Feedback on Help Topics
Page:   OnClose Method (IPropertyManagerPage2Handler6)
*   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:


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

Web Help Content Version: API Help (English only) 2014 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.