Jump to content

New dialog: Difference between revisions

From LabVIEW Wiki
mNo edit summary
mNo edit summary
Line 16: Line 16:
*The '''Help''' button launches the [[LabVIEW Help]] to the help article about the ''New Dialog Box''.
*The '''Help''' button launches the [[LabVIEW Help]] to the help article about the ''New Dialog Box''.


== Basic Usage ==
== New Dialog Source Code ==
The '''New''' dialog is written in [[G]]
 
== Adding to the New Dialog ==
You can add items to the '''New''' dialog without editing the source code.  To do this you will need:
*A [[VI]] that launches you [[Wizard]], or [[VI Scripting]] code that creates the component
*The path to where the VI will be installed (if installed by a [[Package]] or [[Installer]]
*A PNG image that represents your component. This is used in the '''Description''' in the dialog. Size should be 256 x 256 pixels.
*A PNG image to be used as the icon in the '''Create New''' tree in the dialog.  Size should be 16x16 pixels.
*A description of the component to be used in the '''Description''' in the dialog
*Generate a GUID for your component
 
After you have all these items, locate the ''LVNewDialog.xml'' file located in the [[LabVIEW]] directory at: ''resource\plugins\NewDialogFiles\LVNewDialog.xml''.  To add a node to the XML file for your component you will need to read the file and find the GUID for the '''Other Files''' item in the tree.  This becomes the <code><ParentGUID></code> in the node you will add.


::'''Note''' It is advisable to make a backup of your ''LVNewDialog.xml'' before beginning to edit it. It is not impossible to restore if the file is corrupted but it would require a reinstall of [[LabVIEW]] if you did.


== Adding to the New Dialog ==
An example of the XML code for a node is as follows (shown here from the [[QControl|QControl Toolkit]]):
{| class="wikitable"
|-
|
<Node>
:<Name localize="yes">QControl</Name>
:<GUID>%s</GUID>
:<ParentGUID>%s</ParentGUID>
:<ItemPath>/resource/plugins/QControl/New QControl.vi</ItemPath>
:<ItemType>ProjectWizard</ItemType>
:<Description localize="yes">This launches the QControl Creation Wizard to step you through the creation of a new QControl.</Description>
:<ImagePath>/resource/plugins/QControl/QControl Class.png</ImagePath>
:<MagicNumber></MagicNumber>
:<Weight>-1</Weight>
:<Version></Version>
:<ChildOnly>1</ChildOnly>
:<ProjectPossible>0</ProjectPossible>
:<NDIconPath>/resource/plugins/QControl/QControl Class Icon.png</NDIconPath>
</Node>
|}


== New Dialog Source Code ==
Where the ''%s'' under the <code><GUID></code> tag should be replaced with your GUID you generated and the '%s'' under the <code><ParentGUID></code> tag should be replaced with the GUID '''Other Files''' item.  Replace the data in the ''Name'', ''ItemPath'', ''Description'', ''ImagePath'', and ''NDIconPath'' tags with the information about your component from above.  Save the XML and restart [[LabVIEW]] to test.


[[Category:Development Environment]]
[[Category:Development Environment]]

Revision as of 18:02, 25 November 2020

The New dialog provides access to create to [[[VI]]s, Polymorphic VIs, LabVIEW Projects, LabVIEW Classes, LabVIEW Project Libraries, Custom Controls (see Control editor), Run-Time Menus, and XControls. VIs can be created from the New dialog using templates that create the VI with a common Design Patterns already established. Other toolkits, like QControls, add options to create other types of content to the New dialog. To access the New dialog from the Getting Started, Project Explorer, VI Front Panel, or VI Block Diagram windows, select File-->New... from the menu bar.

New dialog box

Dialog Parts

The main parts of the New dialog include:

  • Create New is a tree control that displays starting points for VIs and other LabVIEW documents. Select an item from one of the following categories and click the OK button to start building a VI or other LabVIEW document.
  • Description is a picture control that displays an image and a description of the component you selected in the Create New list.
  • Add to project is a checkbox that specifies if the new component should be added to the project you select in the Projects pull-down menu. If no project is available, LabVIEW disables this checkbox.
  • Projects is a drop-down combobox that specifies the project to which LabVIEW will add the selected component. This pull-down menu appears only if you have more than one project open.
    Note LabVIEW automatically selects and disables the Add to project checkbox. If no project is available, LabVIEW disables the OK button. If multiple projects are available, you can select the project to which you want to add the item from the Projects pull-down menu.
  • The OK button starts creation of the selected component.
  • The Cancel button dismisses the New dialog without creating the selected component.
  • The Help button launches the LabVIEW Help to the help article about the New Dialog Box.

New Dialog Source Code

The New dialog is written in G

Adding to the New Dialog

You can add items to the New dialog without editing the source code. To do this you will need:

  • A VI that launches you Wizard, or VI Scripting code that creates the component
  • The path to where the VI will be installed (if installed by a Package or Installer
  • A PNG image that represents your component. This is used in the Description in the dialog. Size should be 256 x 256 pixels.
  • A PNG image to be used as the icon in the Create New tree in the dialog. Size should be 16x16 pixels.
  • A description of the component to be used in the Description in the dialog
  • Generate a GUID for your component

After you have all these items, locate the LVNewDialog.xml file located in the LabVIEW directory at: resource\plugins\NewDialogFiles\LVNewDialog.xml. To add a node to the XML file for your component you will need to read the file and find the GUID for the Other Files item in the tree. This becomes the <ParentGUID> in the node you will add.

Note It is advisable to make a backup of your LVNewDialog.xml before beginning to edit it. It is not impossible to restore if the file is corrupted but it would require a reinstall of LabVIEW if you did.

An example of the XML code for a node is as follows (shown here from the QControl Toolkit):

<Node>

<Name localize="yes">QControl</Name>
<GUID>%s</GUID>
<ParentGUID>%s</ParentGUID>
<ItemPath>/resource/plugins/QControl/New QControl.vi</ItemPath>
<ItemType>ProjectWizard</ItemType>
<Description localize="yes">This launches the QControl Creation Wizard to step you through the creation of a new QControl.</Description>
<ImagePath>/resource/plugins/QControl/QControl Class.png</ImagePath>
<MagicNumber></MagicNumber>
<Weight>-1</Weight>
<Version></Version>
<ChildOnly>1</ChildOnly>
<ProjectPossible>0</ProjectPossible>
<NDIconPath>/resource/plugins/QControl/QControl Class Icon.png</NDIconPath>

</Node>

Where the %s under the <GUID> tag should be replaced with your GUID you generated and the '%s under the <ParentGUID> tag should be replaced with the GUID Other Files item. Replace the data in the Name, ItemPath, Description, ImagePath, and NDIconPath tags with the information about your component from above. Save the XML and restart LabVIEW to test.