Cancel
Showing results for 
Search instead for 
Did you mean: 

Closing UI Styler GUI once Apply is pressed

Gears Phenom Gears Phenom
Gears 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: NX.CAE 9.0.3.4, NX.CAE 10.0.2.6
Development: VB.NET (amateur level !)
10 REPLIES

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 (TeamCenter11 and Native)

Re: Closing UI Styler GUI once Apply is pressed

Valued Contributor
Valued Contributor

Hello Herbert,

 

I am in a similar situation as described in the original thread. The only difference is that I have created the dialog using Block Styler.

Do you know how can I close a Block Styler UI when an error is encountered . The UI needs to be closed after the error message has been displayed.

Re: Closing UI Styler GUI once Apply is pressed

Phenom
Phenom

I don't think you can. In the past to do this I have resorted to disabling all of the blocks on the dialog and disabling the OK/Apply buttons to prevent the user from doing anything. Then the only option is to click Cancel.

Obvioulsy the error message should inform the user about the error and explain that the dialog is being disabled because of it.

Graham Inchley Snr R&D Engineer (Systems Development), Sandvik Coromant
Lenovo ThinkPad W540, Win7, 16GB. Developing in: Java | C | KF
Production: [NX8.5.3.3 MP11 64bit] Testing: [NX12.0.0.27 MP1]

Re: Closing UI Styler GUI once Apply is pressed

Valued Contributor
Valued Contributor

Hello KushWadhwani,

 

unfortunately I'm not very familiar with BlockDialogs.

 

You should have a callback for the CANCEL button e.g. "cancel_cb".

 

Try to call this when you want to close the dialog (NOT TESTED).

 

Best regards

Herbert

Herbert Macho
EBNER Industrieofenbau
AUSTRIA

NX10.0.3.5 (TeamCenter11 and Native)

Re: Closing UI Styler GUI once Apply is pressed

Phenom
Phenom

Trying to call the cancel_cb() yourself won't help. The action of closing the dialog is taken internally by NX after the OK or Cancel callbacks you implement have executed.

Graham Inchley Snr R&D Engineer (Systems Development), Sandvik Coromant
Lenovo ThinkPad W540, Win7, 16GB. Developing in: Java | C | KF
Production: [NX8.5.3.3 MP11 64bit] Testing: [NX12.0.0.27 MP1]

Re: Closing UI Styler GUI once Apply is pressed

Valued Contributor
Valued Contributor
Hello Inch,

thanks for clarifying this.
Like I have mentioned, I'm not really familiar with the BlockStyler stuff.
I swapped from UIStyler to WinForms....

Best regards
Herbert
Herbert Macho
EBNER Industrieofenbau
AUSTRIA

NX10.0.3.5 (TeamCenter11 and Native)

Re: Closing UI Styler GUI once Apply is pressed

Phenom
Phenom

Err.. you're now introducing WinForms. That is different again:

  • UIStyler - A legacy dialog building environment, usage discouraged, no new development (AFAIK).
  • BlockStyler - The latest dialog building environment. I'm told the NX UI designers use BlockStyler to build the native NX dialogs.
  • WinForms - A dialog building environment out of NX control. Using this you can get the dialog to look just about any way you like, but it has some limitations and complications. How the OK/Apply/Cancel callbacks work with this I have no idea. I'm using Java, so WinfForms is not an option.
Graham Inchley Snr R&D Engineer (Systems Development), Sandvik Coromant
Lenovo ThinkPad W540, Win7, 16GB. Developing in: Java | C | KF
Production: [NX8.5.3.3 MP11 64bit] Testing: [NX12.0.0.27 MP1]

Re: Closing UI Styler GUI once Apply is pressed

Siemens Phenom Siemens Phenom
Siemens Phenom

Graham,

 

I just wanted to say that your earlier comment about making everything on the dialog insensitive except Cancel was a clever approach.  We don't have any supported method to close a Block UI Styler dialog except to use either OK or Cancel - unless the dialog was designed with just a Close button, but that works a lot like OK - your changes are put into effect if possible, and then the dialog is closed.

 

Steve

 

Re: Closing UI Styler GUI once Apply is pressed

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

Note if you created this using a Block Styler dialog, the dialog has a "Navigation style" property which can be set to "OK Cancel" ... so there is no "Apply" button.

Not sure if (due to licensing or whatever) Block Styler is an option for you.

Then you can use the "Enable Apply/OK Callback" function to keep "OK" disabled until everything is OK to apply.

Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP16/TC11.2
I'd rather be e-steamed than e-diseaseled