Tutorial 18 - All about forms
All About Forms by Richard Gamester
By now you have had a play with PPL., tried creating a form, maybe even started to write a program!
So now is the time to learn a bit more about forms and how the compiler keeps track of all your code!
Start PPL and click Project > New
In the new project window. select Blank Project, then type a different name where it says project name. In this document I will use "Test" but the choice is yours. Click the Ok button.
PPL will create a new folder of that name in your project folder.
Click Tools > Visual Editor
A new form will then be created and displayed in the window.
Click an item in the "controls" tool bar, lets say a button (OK).
Now it is time to save your form, click File > Save and save the file in your new folder as Test.frm.
Double click your button. PPL will create a procedure for the (default) OnClick event
Type in a ShowMessage command like this:
Right click the #button101 tab and select close. When asked, say Yes to save it.
With the form showing, click the Form > Initalization Section Code
In the new window type a comment like
// Initalization code here!
Right click on the #%init tab and select close, when asked say yes to save.
Now click Form > Form Creation Code
In the new window type a comment like
// Form code in here!
Right click on the #%create tab and select close, when asked say yes to save.
Let's see the result
Click Form > Create Source
What you see now is the PPL file generated from your work so far. On about line 10 you will see your comment:
// Initalization code here!
This is where you would put the #include statements for other PPL files that you needed in your project.
Following this are the button events (the close menu item is created for you) and the one in which you typed the ShowMessage. In fact, the events for all your controls will be in this area.
Then we get into the form creation code, it starts:
func WinMain
This is where PPL writes all the code required to create your form. Right down at the bottom, you will see:
#code
// Form code in here!
return (true);
end;
You will see that the "form creation code" is just an extension of the PPL generated WinMain function code. The return (true) is added by PPL.
Note that what you are seeing is code generated by PPL. Do NOT try to edit this as your changes will be lost!
PPL keeps the all the events for initialization, form creation and form components separate. This makes it far easier for the user (honest)! It also allows PPL to remove the code if you delete the component.
If you want to edit the form sections you have to return to the form and use the Form menu. For control events double click the control or use the events menu.
Lines like this
#code
are just commands to the compiler to include your text from the Test.frm file.
No Comments
Post a Comment