Finally, mention should be made of the form itself, which is also a visual object. In the case of designing without MCK, the form is created by calling
MyForm: = NewForm (Applet, 'form caption');
Always substitute the Applet variable as the parent parameter in the call. Even if the applet is not used, and the Applet variable is nil, the use of the Applet variable will still be correct, and if you decide that you still need to use a separate Applet object in the project, then you will not have to rewrite the code that constructs the forms. In this case, it will be enough to insert a call before creating the first form.
Applet: = NewApplet ('applet title');
Of course, when designing using MCK, you may not need to write out the code for constructing the form (if all forms are created automatically, and in a single copy). But even in the case of using MCK, nevertheless, the forms may need to be created dynamically. For example, if there are a lot of forms in the project, then to speed up the initial start of the application, it makes sense to postpone the creation of forms until the moment when they are really needed. Or in the case when the same form can be designed more than once to display several of its instances on the screen at a time (without going into the details of why this might be needed).
In this case, pay attention to the specifics of using forms in the case of using MCK. Namely, at the design stage, the MCK mirror of the form (TKOLForm object) generates the code, and in particular, for the form named MyForm, it creates the global function NewMyForm. The definition of this generated function is located in the front-end of the module itself, and its implementation code is in the file <unit_name> _1.inc. To create a form object, the entry will now be different than in the case of "pure" KOL:
NewMyForm (MyForm1, Applet);
As you can see, the variable to which the created form object is assigned has moved from the left side of the assignment operator to the place of the first parameter, and the "title" parameter has disappeared. The form now gets the title in the "constructor" code generated by MCK, based on the settings you made when designing the form.
When designing in MCK, you must select the TKOLForm component on the form to change the properties of the form, and then change something in the Object Inspector. This is mentioned in another section of this book, but it will not be superfluous to repeat it, since we have already talked about the form.
Now I will focus on how the TControl object type works at runtime when it performs the functions of a form. In the case when MCK is used, this is the variable MyForm.Form, in the case of "pure" KOL, this is the variable MyForm itself of the PControl type.
There are the following features: in KOL, the form cannot process the OnClick message (although the OnMouseDown and OnMouseUp events work correctly). In addition, the KeyPreview property is not available by simply assigning TRUE to this property. You must first add the KEY_PREVIEW symbol to the project options.