<!DOCTYPE html
  PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<!--
Copyright (c) 2006 UGS Corp.

All Rights Reserved.

This software and related documentation are proprietary to UGS Corp.
-->
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>Using Native Window Tools</title>
      <script language="javaScript">
        abridged="false";
        displayConditions=new Array();
      </script>
      <link type="text/css" href="../css/main_styles.css" rel="stylesheet">
   </head>
   <body class="bodydocs" onload="top.pageLoader()" bgcolor="#FFFFFF">
      <div class="title_topic2" id="xps10_pagetitle">Using Native Window Tools</div>
      <hr noshade="true">
      <div class="title_division">Introduction</div>
      <p class="para_division">With the implementation of a .NET API for NX, you can now use the .NET WinForms class objects to create interactive NX dialogs. Because journaling uses the same .NET platform as the .NET API, you can also embed WinForm-based dialogs and message windows in your journals.</p>
      <div class="title_division">Inserting a Message Window</div>
      <p class="para_division">You can insert a message window into your journal or automation program using the following VB.NET code:</p><pre class="indent">Messagebox.Show (&quot;Invalid input. Value exceeds given limits!&quot;,
        &quot;Warning&quot;, MessageBoxButtons.OK, MessageBoxIcon.Warning)</pre><p class="para_division">This produces a warning message window with an OK button.</p>
      <table border="0">
         <tr>
            <td valign="top" align="left"><img align="left" src="../graphics/note.gif" alt="Note" title="Note"></td>
            <td valign="bottom" align="left" width="100%">
               <div class="para_note">
                  <p class="para_note_body">When using this message window, include a reference to the System.Windows.Forms library in the Imports section of your code.</p>
               </div>
            </td>
         </tr>
      </table>
      <div class="title_division">Inserting a Text or Numeric Input Form</div>
      <p class="para_division">Because WinForms does not provide a simple text input form, the following custom .Net class was created within the NXOpenUI library as a usability tool for streamlining the customization of a journal or a .NET program.   This class encapsulates simple WinForms code into a single object call to produce a string or numeric input dialog.</p><pre class="indent">double NXInputBox.GetInputNumber (string prompt, string caption, string initial test)</pre><pre class="indent">string NXInputBox.GetInputString (string prompt, string caption, string initial test)</pre><p class="para_division">Both methods produce simple dialogs that prompt a user for an input string or number. For example, the following journal was recorded while Sketch Preferences were set. A text input form that prompts the user to insert a prefix for sketch names was then added to the journal.</p><pre class="indent">Option Strict Off
Imports System
Imports NXOpen
Imports NXOpenUI

Module NXJournal
Sub Main

Dim theSession As Session = Session.GetSession()

Dim sketchName As String
sketchName = NXInputBox.GetInputString (&quot;Insert Sketch Prefix:&quot;, &quot;Sketch Name&quot;, &quot;None&quot;)

' ----------------------------------------------
'   Menu: Preferences-&gt;Sketch...
' ----------------------------------------------
theSession.Preferences.Sketch.DefaultSketchNamePrefix = sketchName
theSession.Preferences.Sketch.DefaultVertexNamePrefix = &quot;VERTEX&quot;
theSession.Preferences.Sketch.DefaultLineNamePrefix = &quot;LINE&quot;
theSession.Preferences.Sketch.DefaultArcNamePrefix = &quot;ARC&quot;
theSession.Preferences.Sketch.DefaultConicNamePrefix = &quot;CONIC&quot;
theSession.Preferences.Sketch.DefaultSplineNamePrefix = &quot;SPLINE&quot;
theSession.Preferences.Sketch.SnapAngle = 3
theSession.Preferences.Sketch.TextHeight = 0.15
theSession.Preferences.Sketch.DecimalPlaces = 3
theSession.Preferences.Sketch.DimensionLabel = SketchPreferences.DimensionLabelType.Expression
theSession.Preferences.Sketch.ChangeViewOrientation = True
theSession.Preferences.Sketch.MaintainLayerStatus = True
theSession.Preferences.Sketch.DisplayDOFArrows = True
theSession.Preferences.Sketch.RetainDimensions = False
theSession.Preferences.Sketch.DynamicConstraintDisplay = True
' ----------------------------------------------
'   Menu: Tools-&gt;Journal-&gt;Stop
' ----------------------------------------------

End Sub
End Module</pre></body>
</html>