[fpc-pascal] Directory Tree

Jean SUZINEAU jean.suzineau at wanadoo.fr
Mon Apr 26 00:59:29 CEST 2021


Le 25/04/2021 à 21:30, James Richters via fpc-pascal a écrit :
>            >I added LoadFromFile in this event.
> That was the first thing I tried, but the problem is, this happens before anything is put on the screen.. so when I run the program with an Ini file with 4000 entries in it, there is a good 30 second delay, and then the screen is shown with everything loaded.
>
> So I tried putting it in various places in the form, but then it runs additionally when I don’t want it to.
>
> The problem I’m having is understanding the sequence of things (if there even is one)  with my console programs, I specifically determine the exact order I want things to run, but this is more just a collection of things that all run at the same time.. well they don’t run at the same time, it’s an illusion, computers only do one thing at a time.. but I don’t understand how this illusion is controlled…how can I order it to show form1, show the buttons, show the load bar graph… get everything on the screen, THEN load the last used file?  I can’t really use config.ini, because in order to get everything on the screen in the proper size and position, the configuration would have had to be read in already.. so before anything is displayed.. I want the load to happen after everything is displayed.  I supposed I can maybe launch a timer to wait 1 second to get everything on the screen then load the files, but I don’t even know where to put the timer.

I'm not an expert of that, but let's say that since the good old time of 
Windows 3.1, your Windows app is based on a so-called "message loop".
The main part of your app just register a callback for processing a 
message. There are hundreds of different kind of messages ( from the 
Windows emulator in linux: 
https://wiki.winehq.org/List_Of_Windows_Messages )

Windows kernel is running the loop and sometimes calls your callback to 
repaint a window, set the focus, notify you of a mouse move ....
You can still make your own callback ( 
https://docs.microsoft.com/en-us/windows/win32/winmsg/using-window-procedures 
).
But it's so complex that in practice we uses base classes like 
TApplication and TForm to do all the basic code of the windows app.
In the times of Windows 3.1 made for single task  processors, I think 
there were a single message loop for all the system, shared by all the 
apps. If you took too much time processing one of your messages you 
could hang up the system. It was non-preemptive multitasking.
With Windows 95 and 32 bits it began to use the multitasking capability 
of the processor, it began to be preemptive multitasking, you couldn't 
lock the system with an infinite loop, just your program.
With the advent of multicore processors, I think that now you can have 
really several assembler instructions running in parallel 
(https://en.wikipedia.org/wiki/Multi-core_processor).
In some cases you can accelerate your program by running several threads 
in parallel with the TThread class for example.

Most of your components (TEdit, TButton) are child windows hosted in the 
form parent window and they receive their own messages for painting, 
mouse, ...

I have moved the LoadFromFile to a Timer event just fired on creation of 
the Form with 10ms. When the message of the timer arrives,  usually all 
the loading an painting is already done, their messages have been posted 
before in the message queue.

> I'm not getting the page break in word either.
May be the template is not up to date ? I think that after type 
Ctrl+Enter in the template Libre Office adds a parameter for allowing 
soft page breaks.


More information about the fpc-pascal mailing list