Back to Concepts and HOW TOs
Description
You can either add a Main class (with associated run functions) to your main AppProject, or assign an existing class and functions to these roles. You can also embed another form within your Main form.
Procedures
Adding a Main Class and Its Functions
To add a main class and run functions to your AppProject
- If you have not done so, add an AppProject you want to act as the entry point to your application. Be sure to choose the Main Class template for your AppProject.
Or - If you already added the AppProject, but did not choose the Main Class template, in the Solution Explorer, select your AppProject.
- On the Solution Explorer toolbar, click the orange Add Class button. Follow the steps to add a class, being sure that you have the correct project displayed in the Project drop-down box (should be the name of the AppProject to which you are adding the class). Also, be sure to choose Application as the the superclass type for your new class.
- The Main class appears under your AppProject, and the run and afterRenderInitialization functions appear in the Solution Details.
Making an Existing Class Your Main Class
To make an existing class your main class
- If you have not done so, add an AppProject you want to act as the entry point to your application.
- Select the AppProject, then on the General tab of the Property Editor, on the Application property click the ellipsis button [...] and choose the class you want to assign as the "main" class of your application.
Note You are constrained by the interface to select only a class that inherits from Application. If you do not have such a class in your solution, you must either use the Inherits From property to change the superclass of the class in your solution that you want to act as your Main class, or add a class to your solution, being sure to choose Application as the superclass. If the class does not already implement the Main class functions, you can add overrides of the Application superclass' functions.
- Unless you want your application to be a no GUI application process, you must designate a "main form" for your application. The form you want to act as the main form for your application must belong to the class you designate as the Main class for your application, though you can embed a form belonging to a different class within the main form of your application. There are two ways to designate a main form in your Main class:
- Select the form in your Main class that you want to be your application's main form, then use the Interface List property to choose the system provided Main form interface (on the Runtime tab). If you do this, at runtime, the application machinery can find your main form.
- Alternatively, override the getMainForm function of the Application class, then pass the form interface of the form you want to be the main form to the argument of the getMainForm function.
- Add the main and postRenderInit overrides as needed, and provide any needed logic to these functions.
Embedding a Previously Constructed Form within your Main Form
If you added functionality in a different class or project, and you decide you want that functionality available in your Main class, you can make that functionality available within your AppProject's Main form.
To embed a previously constructed form within your main form
- In the Solution Explorer, expand your AppProject, and select your Main class, then add a field to your class.
- Change the type of the field you just added to the class which contains the form you want to be your Main form.
- In the Solution Explorer, select your AppProject's Main class, so that the Main form is visible in the Solution Detail, then double-click the Main form.
- In the Design Editor, edit the form so that it corresponds to the size of the form you want to embed (remove any extraneous cell dividers as well).
- Next, in the Solution Explorer select the field you added to your Main class, then drag and drop a DynamicForm control onto the Main Form.
- Select the DynamicForm, then in the Property Editor, select the Interface tab.
- In the left-hand column of the Property Editor, select the Form property under Forms, then click the ellipsis button [...] next to Form Interface, and in the Choose FormInterface dialog, change the interface to match the form interface on the form you want to appear as your Main form.
Note If you are unsure which interface to choose, inspect the Interface List property on the form you want to appear in your Main form.
- Click OK. Your form should now appear inside the DynamicForm. To see how your new Main form looks, simulate your application by clicking the Run button.