Forum > Beginners

Program flow

(1/2) > >>

lewhite:
I'm trying to find examples of program flow in the documentation.  Where do I find illustrations of using (as examples) application.run or application.terminate or application.xxxx topics? If I have some code I want run after the main form has been created but the form is displayed, where do I put it?.  If I used multiple forms, is there a formx.show or something simliar? Seems to me like there must be a long list of functions / methods / procedures that can be used that I cannot find reference to in the free pascal / Lazarus documentation. Thanks

Handoko:
Hello lewhite,
Welcome to the forum.

Maybe these can be useful for you:

Documentation about TApplication:
http://lazarus-ccr.sourceforge.net/docs/lcl/forms/tapplication.html

TForm tutorial:
http://wiki.freepascal.org/Form_Tutorial#Two_Forms_That_Can_Call_Each_Other

Execution order:
http://forum.lazarus.freepascal.org/index.php/topic,37784.msg254958.html#msg254958

molly:
Handoko already gave you some good links, however those would perhaps not answer all your question or discuss all options.


--- Quote from: lewhite on September 26, 2017, 01:49:20 am ---If I have some code I want run after the main form has been created but the form is displayed, where do I put it?.

--- End quote ---
There are several options, alll have their pro's and con's.

For example, you could use the onShow event, but that fires every time your form is 'shown'. If that event only happens once for the duration of your application then that is fine, otherwise you would have to account for your code to run oly once (that is, if your code is only suppose to run once).

Another option is using the Application onidle event, again you would have to account foronly running the code once as the onidle event is fired quite a lot.

Using a timer on your form is also an option. you would then put your code at the ontimer event and disable the timer once your code has run.

I'm sure i forgot to mention many other solution or approach. It kind of depends on what should be done exactly where and if it fits your program's flow.

--- Quote ---If I used multiple forms, is there a formx.show or something simliar? Seems to me like there must be a long list of functions / methods / procedures that can be used that I cannot find reference to in the free pascal / Lazarus documentation. Thanks

--- End quote ---
Look at your applications .lpr file. There is where your application object gets initialized and forms are created and added. Do realize that the code you see in there can be manipulated with your project's settings, e.g. you can tell your project which forms should be created automatically for you (or not).

RAW:

--- Quote ---If I have some code I want run after the main form has been created ....

--- End quote ---
It depends on what you really want to achieve...  :)

This would be one way...

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---// PRIVATE//  booOnce: Boolean;Procedure TForm1.FormPaint(Sender: TObject); Begin  If Not booOnce  Then   Begin    ShowMessage('OnPaint');    booOnce:= True;   End; End;

RAW:
Or like this...


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Procedure TForm1.FormClick(Sender: TObject);  Var   wnd: TForm; Begin  wnd            := TForm.Create(Self);  wnd.Caption    := 'MyNewWindow';  wnd.SetBounds  (300, 300, 300, 300);  wnd.PopupMode  := pmExplicit;  wnd.PopupParent:= Self;  wnd.Show;   ShowMessage('After creating my new window...'); End;

Navigation

[0] Message Index

[#] Next page

Go to full version