[Lazarus] sleep function don't passed before executing the next statement

Eric Kom erickom at metropolitancollege.co.za
Mon Nov 19 16:21:49 CET 2012


On 19/11/2012 14:44, Martin wrote:
> On 19/11/2012 12:17, Eric Kom wrote:
>> On 19/11/2012 13:07, Michael Schnell wrote:
>>> On 11/19/2012 11:01 AM, Eric Kom wrote:
>>>> the Connection procedure is declared as a private
>>>>
>>> This makes no difference at all.
>>>
>>> ("private" is just a visibility attribute and has no influence on 
>>> the functionality whatsoever. Please read the docs on the Object 
>>> Pascal language.)
>> Please did know a link that can send me to Object Pascal Language guide?
>
> This isn't so much about object programming, but about event driven 
> programming.
>
> Events are processed one by one. Your "Tfrmform1.Connection" is one 
> event. All other events are only processed, when this 
> returns/finishes. (or when you call Application.ProcessMessages)
>
> "StatusBar.SimpleText := 'My name is Tux'; "
> Does store the new caption, but not yet paint it. It triggers a paint 
> event, that will be processed later.
>
> During the sleep no events are processed, so nothing is painted to the 
> screen.
>
> You could call Application.ProcessMessages before the sleep. But 
> *warning*, this can get messy. During a Application.ProcessMessages 
> your event ("Tfrmform1.Connection") can be triggered and called again, 
> like this:
>     StatusBar.SimpleText := 'My name is Tux';
>     Application.ProcessMessages;
>           StatusBar.SimpleText := 'My name is Tux';
>           Application.ProcessMessages
>                  // ... and maybe called again ...
>           sleep(100);
>           StatusBar.SimpleText := 'am ready';
>     sleep(100);
>     StatusBar.SimpleText := 'am ready';
>
>
Thanks for all Martin, it's works

StatusBar.SimpleText := 'My name is Tux';
StatusBar.Update;
sleep(2000);
StatusBar.SimpleText := 'am ready';

I will try the hard code also


> You can also try
>   StatusBar.Update;
> This will (or should) do an immediate paint (do NOT call paint directly!)
>
>
> Also note: during a sleep your app does not react. If a user resizez 
> the window, it will not paint. So if you put is longer sleeps, your 
> app will become none responsive to the user.
>
>
> -- 
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>


-- 
Kind Regards

Eric Kom

System Administrator - Metropolitan College
  _________________________________________
/ You are scrupulously honest, frank, and \
| straightforward. Therefore you have few |
\ friends.                                /
  -----------------------------------------
    \
     \
         .--.
        |o_o |
        |:_/ |
       //   \ \
      (| Kom | )
     /'\_   _/`\
     \___)=(___/

2 Hennie Van Till, White River, 1240
Tel: 013 750 2255 | Fax: 013 750 0105 | Cell: 078 879 1334
erickom at kom.za.net | erickom at metropolitancollege.co.za
www.kom.za.net | www.kom.za.org | www.erickom.co.za

Key fingerprint: 513E E91A C243 3020 8735 09BB 2DBC 5AD7 A9DA 1EF5





More information about the Lazarus mailing list