Hide Table of Contents
OnClose Method (IPropertyManagerPage2Handler7)

Called when this PropertyManager page is closing.

.NET Syntax

Visual Basic (Declaration) 
Sub OnClose( _
   ByVal Reason As Integer _
) 
Visual Basic (Usage) 
Dim instance As IPropertyManagerPage2Handler7
Dim Reason As Integer
 
instance.OnClose(Reason)
C# 
void OnClose( 
   int Reason
)
C++/CLI 
void OnClose( 
&   int Reason
) 

Parameters

Reason

Reason this method is called as defined in swPropertyManagerPageCloseReasons_e

Example

Remarks

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 PropertyManager2Handler7::OnClose handler because the PropertyManager page and command are closing. So, typically the IPropertyPage2Handler7::AfterClose handler is called after IPropertyManager2Handler7::OnClose to allow an add-in to do work. However:

 

If PropertyManager page is...

And you implemented the handler in...

Then you...

Not pinned

C++

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 IPropertyManagerPage2Handler7::AfterClose handler is not called.

Pinned

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 IPropertyManagerPage2Handler7::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.

To close a pinned PropertyManager page by raising an exception, your application has to clear all selections by calling IModelDoc2::ClearSelection2(true) in the call to IPropertyManagerPage2Handler7::OnClose. The PropertyManager page will not close if selections exist.

 

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

Availability

SolidWorks 2010 FCS, Revision Number 18.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

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