Lazarus

Free Pascal => Beginners => Topic started by: JLWest on December 08, 2018, 08:52:47 pm

Title: An Idle Question
Post by: JLWest on December 08, 2018, 08:52:47 pm
Am I the only customer you guys got? You guys are going to have to come up with more beginners. I don't think I can keep you that busy. Well maybe I can.

I have a form with a 5 listboxes that I load out of the FormShow event.

Then the user has to press one of several buttons to do various process.

After loading the last listbox out of FormShow is their a command I can issue that puts the program in idle or something.
Title: Re: An Idle Question
Post by: jamie on December 08, 2018, 09:19:56 pm
I guess If the user does not interact with it then it is considered inactive ?

But if you want to do things like send the app the back of all others you can.

you have "SendToBack", "BringTofront"

If you want to minimize the form to the taskbar you can do this..

WindowStte := wsMinimized;

that works for the main form so the whole app gets minimized.

Things to play with..

Title: Re: An Idle Question
Post by: lucamar on December 08, 2018, 09:38:58 pm
Modern OSs and modern applications are able to manage their time quite well. After your code is executed your applicaiton will look to the message queue and enter, by itself, an idle state if there's nothing there for it to do; the OS, for its part, will (try to) make sure your program doesn't consume an inordinate amount of time doing its thing and will stop your application until there's something for it to do.

Of course, all is not as simple: this is just the ultra-very schematic explanation. The point is that your application will probably be idle more time than working already. So ...

What is it exactly you want to do?
Title: Re: An Idle Question
Post by: JLWest on December 08, 2018, 11:05:37 pm
Maybe I didn't explain myself very well.
Out of the procedure FormShow I do the following;

procedure TFMain.FormShow(Sender: TObject);
Begin
Load ICOAS
LoadRoutes
Load Airports
End;

The process flow is after Load ICOAS it comes back and executes LoadRoutes
returns and executes LoadAorports comes back and it now on the end statement.


Then the form appears.

Can I assume it waiting for a button press or something from the user.

I assume there is nothing I can code after Load Airports to tell the program to go idle or park until called.

 

Title: Re: An Idle Question
Post by: lucamar on December 08, 2018, 11:15:13 pm
Can I assume it waiting for a button press or something from the user.

Yes, of course. Once all the initialization is done, the form shown, etc. the program does nothing but wait for the user to do something--unless you have an active timer or thread os something like that.

Quote
I assume there is nothing I can code after Load Airports to tell the program to go idle or park until called.

Not really, unless by "park" you mean going to sleep() or something like that. If you mean just "idle, waiting for events" then the program is already in that state. You need do nothing more.

Incidentally, why don't you do all your LoadXXX in the OnCreate event? Unlike OnShow, OnCreate is guaranteed to be called just once in the life of the form, and by then all the design-time controls have been created already.
Title: Re: An Idle Question
Post by: JLWest on December 09, 2018, 12:38:46 am
Thank You. Yea, that sounds like a good Idea.
Title: Re: An Idle Question
Post by: Handoko on December 09, 2018, 03:04:39 am
This wiki page may help you better understand event order:
http://wiki.freepascal.org/Event_order

And try this RAW's demo code:
http://forum.lazarus.freepascal.org/index.php/topic,37600.msg253236.html#msg253236
TinyPortal © 2005-2018