[fpc-pascal] Windows programming tutorials for FPC

Luca Olivetti luca at ventoso.org
Sun Nov 4 19:39:14 CET 2018


El 4/11/18 a les 17:29, James ha escrit:
> I used System.Assign and now I have my program working in Lazarus,  I am exploring both options of making it a real windows application with Lazarus and a console program that can launch save-as.
> 
> The Lazarus version is mostly working in Lazarus, but instead of everything happening before the form is loaded, is there a way I could make the form first, then just start processing everything, so that my messages I send to memo1 show up as it's processing?  I'm guessing I need to move my program from On-create to somewhere else so it runs after the memo box is showing... but I don't know where I would move it to.  Any suggestions?

Oh, I thought you just wanted the program to work as a normal console 
(silent) application and just show the form in case of errors.

Try this: instead of OnCreate use Onshow, but don't put your code there, 
just this

   Application.QueueAsyncCall(@MyProc,0)

then put the cursor on MyProc and press CTRL+SHIFT+C, now lazarus will 
automatically declare the MyProc method. You can put your code there.
It will be invoked asynchronously once the form has been shown.
The problem is, while your loop is running the form will be totally 
unresponsive, it won't even show the lines you add to the memo.
To avoid it you could either put your code in a thread (difficult) in 
order not to stall the gui, or simply call Application.ProcessMessages 
from time to time, e.g. when you add a line to the memo.

Bye
-- 
Luca



More information about the fpc-pascal mailing list