Board index » delphi » Application.ProcessMessages ?

Application.ProcessMessages ?

Hallo.

I have a loop doing some graphics. To be nice my program calls regulary  
Application.ProcessMessages.

Now my question: Clicks on TBitbtns "while" painting the graphics call the  
correct handlers as expected, but choosing Close from the systemmenu or  
clicking the window close button does not terminate the program as  
expected immediately but after finishing the graphics routine. Why is this  
so and how can I change this behaviour ?

        Mls, Kay

 

Re:Application.ProcessMessages ?


Quote
Kay Hayen wrote:
> I have a loop doing some graphics. To be nice my program calls regulary
> Application.ProcessMessages.
> Now my question: Clicks on TBitbtns "while" painting the graphics call the
> correct handlers as expected, but choosing Close from the systemmenu or
> clicking the window close button does not terminate the program as
> expected immediately but after finishing the graphics routine. Why is this
> so and how can I change this behaviour ?

Use update instead.
 _
| | |  _     _        http://www.stud.unit.no/~olavb/
|_| |_|_|_|_|                            Ol...@dds.nl
Eyecom Images, Amsterdam    finger:Ol...@stud.unit.no

Re:Application.ProcessMessages ?


Quote
k...@edition.bonbit.org (Kay Hayen) wrote:
>Hallo.
>I have a loop doing some graphics. To be nice my program calls regulary  
>Application.ProcessMessages.
>Now my question: Clicks on TBitbtns "while" painting the graphics call the  
>correct handlers as expected, but choosing Close from the systemmenu or  
>clicking the window close button does not terminate the program as  
>expected immediately but after finishing the graphics routine. Why is this  
>so and how can I change this behaviour ?
>        Mls, Kay

Kay --

Add

or Application.Terminated

to the loop with the Application.ProcessMessages in it.

Nick Hodges
http://www.apci.net/~nhodges

Re:Application.ProcessMessages ?


On Thu, 19 Sep 1996 01:48:09 GMT, son...@pacific.net.sg (Song Weng
Sam) you smacked the keyboard repeatedly to write:

[Snip]

Quote
>Can you elaborate more on your solution?  I have the following delay
>procedure and my question is how or where should I put
>Application.Terminated?  Please advise.

>TIA.

>procedure TfrmChartMain.Delay(Period: LongInt);
>var
>   FirstTickCount: LongInt;
>begin
>   FirstTickCount := GetTickCount;
>   repeat
>      Application.ProcessMessages;
>   until ((GetTickCount-FirstTickCount) >= Period);
>end;

I'm not Nick, but to answer your question:

   repeat
      Application.ProcessMessages;
   until ((GetTickCount-FirstTickCount) >= Period) or
(Application.Terminated);

should do the trick.

Brien King
bk...@primenet.com

Re:Application.ProcessMessages ?


On Tue, 17 Sep 1996 00:52:12 GMT, nhod...@apci.net (Nick Hodges)
wrote:

Quote
~...@edition.bonbit.org (Kay Hayen) wrote:

~
~>I have a loop doing some graphics. To be nice my program calls regulary  
~>Application.ProcessMessages.
~
~>Now my question: Clicks on TBitbtns "while" painting the graphics call the  
~>correct handlers as expected, but choosing Close from the systemmenu or  
~>clicking the window close button does not terminate the program as  
~>expected immediately but after finishing the graphics routine. Why is this  
~>so and how can I change this behaviour ?
~
~Kay --
~
~Add
~
~or Application.Terminated
~
~to the loop with the Application.ProcessMessages in it.

Hi Nick,

Can you elaborate more on your solution?  I have the following delay
procedure and my question is how or where should I put
Application.Terminated?  Please advise.

TIA.

procedure TfrmChartMain.Delay(Period: LongInt);
var
   FirstTickCount: LongInt;
begin
   FirstTickCount := GetTickCount;
   repeat
      Application.ProcessMessages;
   until ((GetTickCount-FirstTickCount) >= Period);
end;

Finest Regards,
Sam

 _       __    _____    _____            
| |     / /   / ___/   / ___/ ____   ____   ____ _
| | /| / /    \__ \    \__ \ / __ \ / __ \ / __ `/
| |/ |/ /  _ ___/ / _ ___/ // /_/ // / / // /_/ /
|__/|__/  (_)____/ (_)____/ \____//_/ /_/ \__, /
                                         /____/
**************************************************
   From the desk of Song Weng Sam

   Email : son...@pacific.net.sg
   WWW   : http://home.pacific.net.sg/~songws/SAM
   Tel   : (65)-271-7075 (0ffice)
   Pager : 9-492-4014
**************************************************

Re:Application.ProcessMessages ?


On 18 Sep 1996 10:08:02 -0700, bk...@primenet.com (Brien King) wrote:

~On Thu, 19 Sep 1996 01:48:09 GMT, son...@pacific.net.sg (Song Weng
~Sam) you smacked the keyboard repeatedly to write:
~
~[Snip]
~
~>Can you elaborate more on your solution?  I have the following delay
~>procedure and my question is how or where should I put
~>Application.Terminated?  Please advise.
~>
~>TIA.
~>
~>procedure TfrmChartMain.Delay(Period: LongInt);
~>var
~>   FirstTickCount: LongInt;
~>begin
~>   FirstTickCount := GetTickCount;
~>   repeat
~>      Application.ProcessMessages;
~>   until ((GetTickCount-FirstTickCount) >= Period);
~>end;
~
~I'm not Nick, but to answer your question:
~
~   repeat
~      Application.ProcessMessages;
~   until ((GetTickCount-FirstTickCount) >= Period) or
~(Application.Terminated);
~
~should do the trick.
~
~
~
~Brien King
~bk...@primenet.com

Hi Brien,

Thanks a lot for the tips.  You have been most helpful.

Finest Regards,
Sam

 _       __    _____    _____            
| |     / /   / ___/   / ___/ ____   ____   ____ _
| | /| / /    \__ \    \__ \ / __ \ / __ \ / __ `/
| |/ |/ /  _ ___/ / _ ___/ // /_/ // / / // /_/ /
|__/|__/  (_)____/ (_)____/ \____//_/ /_/ \__, /
                                         /____/
**************************************************
   From the desk of Song Weng Sam

   Email : son...@pacific.net.sg
   WWW   : http://home.pacific.net.sg/~songws/SAM
   Tel   : (65)-271-7075 (0ffice)
   Pager : 9-492-4014
**************************************************

Re:Application.ProcessMessages ?


Of course, you could do something like:

if Application.Terminated then
  Abort;

If your program is correctly structured this should work regardless of the
number of loops.

Good luck,

Eric.

In article <3241ec61.5023...@news.singnet.com.sg>, son...@pacific.net.sg
says...

Quote

>On 18 Sep 1996 10:08:02 -0700, bk...@primenet.com (Brien King) wrote:

>~On Thu, 19 Sep 1996 01:48:09 GMT, son...@pacific.net.sg (Song Weng
>~Sam) you smacked the keyboard repeatedly to write:
>~
>~[Snip, Snippety Snip]
>~
>~I'm not Nick, but to answer your question:
>~
>~   repeat
>~      Application.ProcessMessages;
>~   until ((GetTickCount-FirstTickCount) >= Period) or
>~(Application.Terminated);
>~
>~should do the trick.
>~
>~Brien King
>~bk...@primenet.com

Other Threads