cancel
Showing results for 
Search instead for 
Did you mean: 

Closing UI Styler GUI once Apply is pressed

Phenom
Phenom

To all

 

I have a GUI created using UI styler and I want to close the GUI once the user has pressed Apply (or OK). How does one do that? The following code at the end of the apply_cb() function does close the GUI but also issue an error message about memory violation

 

If errorCode = 0 Then
 theDialog.Dispose()
 GetOnWithIt()
End If

 

Thanks

 

Regards

 

JXB

Production: NX9.0.3.4, NX10.0.2.6
Development: VB.NET (amateur level !)
1 REPLY

Re: Closing UI Styler GUI once Apply is pressed

Valued Contributor
Valued Contributor

Apply is ment not to close the dialog, OK normally closes the dialog.

 

Try to create a basic UIStyler dialog with callbacks for APPLY, OK and CANCEL button.

 

Below is the callback code for ok_cb, apply_cb and cancel_cb created in UIStyler:

    '------------------------------------------------------------------------------
    '------------------------- UIStyler Callback Functions ------------------------
    '------------------------------------------------------------------------------


    '------------------------------------------------------------------------------
    ' Callback Name: ok_cb
    ' Following callback is associated with the "testDialog" Styler item.
    ' Input: eventObject - object of UIStyler.StylerEvent class
    '------------------------------------------------------------------------------
    Public Function ok_cb(ByVal eventObject As NXOpen.UIStyler.StylerEvent) As NXOpen.UIStyler.DialogState
        Try
            

            ' ---- Enter your callback code here -----
            

        Catch ex As NXException
            ' ---- Enter your exception handling code here -----
            theUI.NXMessageBox.Show("UI Styler", NXMessageBox.DialogType.Error, ex.Message)
        End Try
        ' Callback acknowledged, terminate dialog
        ' It is STRONGLY recommanded that you exit your
        ' callback with NXOpen.UIStyler.DialogState.ExitDialog in a ok callback.
        ok_cb = NXOpen.UIStyler.DialogState.ExitDialog
    End Function

    '------------------------------------------------------------------------------
    ' Callback Name: apply_cb
    ' Following callback is associated with the "testDialog" Styler item.
    ' Input: eventObject - object of UIStyler.StylerEvent class
    '------------------------------------------------------------------------------
    Public Function apply_cb(ByVal eventObject As NXOpen.UIStyler.StylerEvent) As NXOpen.UIStyler.DialogState
        Try
            

            ' ---- Enter your callback code here -----
            

        Catch ex As NXException
            ' ---- Enter your exception handling code here -----
            theUI.NXMessageBox.Show("UI Styler", NXMessageBox.DialogType.Error, ex.Message)
        End Try
        ' Callback acknowledged, do not terminate dialog
        ' A return value of NXOpen.UIStyler.DialogState.ExitDialog will not be accepted
        ' for this callback type. You must respond to your apply button.
        apply_cb = NXOpen.UIStyler.DialogState.ContinueDialog
    End Function

    '------------------------------------------------------------------------------
    ' Callback Name: cancel_cb
    ' Following callback is associated with the "testDialog" Styler item.
    ' Input: eventObject - object of UIStyler.StylerEvent class
    '------------------------------------------------------------------------------
    Public Function cancel_cb(ByVal eventObject As NXOpen.UIStyler.StylerEvent) As NXOpen.UIStyler.DialogState
        Try
            

            ' ---- Enter your callback code here -----
            

        Catch ex As NXException
            ' ---- Enter your exception handling code here -----
            theUI.NXMessageBox.Show("UI Styler", NXMessageBox.DialogType.Error, ex.Message)
        End Try
        ' Callback acknowledged, terminate dialog
        ' It is STRONGLY recommanded that you exit your
        ' callback with NXOpen.UIStyler.DialogState.ExitDialog in a cancel callback
        ' rather than NXOpen.UIStyler.DialogState.ContinueDialog
        cancel_cb = NXOpen.UIStyler.DialogState.ExitDialog
    End Function

 

The key is the dialog state:

NXOpen.UIStyler.DialogState.ContinueDialog will NOT close the dialog

NXOpen.UIStyler.DialogState.ExitDialog will close the dialog

 

 

Hope this helps

Greetings

Herbert Macho
EBNER Industrieofenbau
AUSTRIA

NX10.0.3.5 (TeamCenter10 and Native)