This topic contains the following sections.
The following topics are included for experienced application developers.
The Application Wizard converts a saved QuickBuild application into a Windows executable as well as a .NET control. Use the executable to run your complete vision application or use the .NET control as part of a custom application you create with Microsoft Visual Studio. The Application Wizard can generate C# or VB.NET source code for supported versions of Visual Studio, or you can configure the wizard to finish the conversion without generating any source code.
The source code allows you to make changes to converted application. Be aware, however, that if you make changes to the source code and then reconvert the original application with the Application Wizard, your changes will be lost. To resolve this problem, the Application Wizard provides templates which allow you to customize your application and to have these custom code changes retained if you rerun the Wizard.
A template is a complete solution in a given language (C# or VB.NET), that contains all the common code between all Wizard-generated applications. This is the code the Wizard begins with every time it is run, regardless of the application. The template project source code contains “formatted comments” which indicate where specific sections of application code are to be inserted by the Wizard. It is the combination of the template code and the Wizard-generated application code that forms the Application Wizard output. By carefully making your own custom modifications to the template code, you can cause the Application Wizard to produce a customized application every time it is run.
Each VisionPro release contains an Application Wizard template, stored by default under Program Files\Cognex\VisionPro\Templates\ApplicationWizard\Current. When you run the Application Wizard it always uses the template in the Current directory. If you choose to use customized templates and possibly have more than one version, you may wish to store your templates in your own private directories. Then, before running the Application Wizard you will need to copy the desired template into the Wizard's Current directory. When copying a template to the Wizard's Current directory, first delete the Current directory contents, then copy in the new template. This ensures the Current directory contains only your desired template.
The Templates directories and subdirectories are described in the following table:
| Directory | Contents |
| Current | The Application Wizard output executable and .NET control are built using the template in this directory. Copy the desired template into this directory before running the Application Wizard The Application Wizard does not alter the contents of this directory |
| C# | Template source code in C# |
| VB.NET | Template source code in VB.NET |
| Strings | Text string files used with the template that localize your application |
You can customize most of the strings that the generated application uses in its buttons, dialog boxes, titles, and other parts of its user interface. These are known as localized text strings and include items such as the Run Once button, the Run Continuous button, the word Offline, and so on. It does not include items such as the user-selected caption labels. You should enter these labels directly when you run the Wizard. These strings allow you to label your application controls using the language appropriate to your locale.
You can find these strings in the file \Program Files\Cognex\VisionPro\Templates\ApplicationWizard\Current\strings\strings-control.txt. You can edit this file to suit your application or to create a localized version. If you choose to modify this file, be sure to keep a copy of your changes outside the VisionPro installation directory so your changes won't be overwritten if you need to reinstall VisionPro.
Note that while the target application will load these strings and display them in the appropriate buttons, labels, and so on, no attempt is made by the template code to change the size of the controls based on the text supplied. So, it is up to the application designer to specify strings that fit the control display space or to customize the template dialogs as needed.
All text string files reside in the strings subdirectory within each template directory (see directory structure details in the figure above). The default strings file (generally containing English language strings) is named “strings-[templatename].txt”. Strings files for other languages should be named using the standard culture abbreviations (Japanese=”strings-[templatename].ja.txt”, German=”strings-[templatename].de.txt”, and so on).
The Application Wizard first looks for a strings file for the current locale. If one is found, it is used to generate the application. If a strings file for the current locale is not found, then the default file (“strings-[templatename].txt”, generally English) is used to generate the application.
The Application Wizard will convert the selected text file to a resx file, which becomes part of the target application source code and will be compiled into the executable.
Note that many strings in the target application cannot be localized, such as data returned from QuickBuild and VisionPro.