Board index » delphi » Form won't close immediately

Form won't close immediately

I have a modal form with an OK button. When this button is pressed, a
long loop starts which draws pixels on the main form. Problem is, the
dialog form won't close until the loop has finished. I have tried
Application.ProcessMessages both before and inside the loop with no
effect.

 

Re:Form won't close immediately


In article <3410638C.DCE5...@hellerud.vgs.no>, Tore Ottinsen

Quote
<tor...@hellerud.vgs.no> writes:
>I have a modal form with an OK button. When this button is pressed, a
>long loop starts which draws pixels on the main form. Problem is, the
>dialog form won't close until the loop has finished. I have tried
>Application.ProcessMessages both before and inside the loop with no
>effect.

Try using the OK return value from the modal form.  Not sure how the modal
form is set up but either move the long loop object to the main form and
execute the loop conditionally from the button pushed on the modal form,  
or leave the the loop in the modal form and 'uses' it from the main form
with the same button conditions.

Re:Form won't close immediately


Quote
In article <3410638C.DCE5...@hellerud.vgs.no>, tor...@hellerud.vgs.no wrote:
>I have a modal form with an OK button. When this button is pressed, a
>long loop starts which draws pixels on the main form. Problem is, the
>dialog form won't close until the loop has finished. I have tried
>Application.ProcessMessages both before and inside the loop with no
>effect.

You might want to check Application.Terminated in your loop.  That closing
the form may set the closing of the app in motion, but it's still looping
through your code - simply booting right out of whatever code you're
performing would typically be a very {*word*194} thing to do.

(After all, what if you're saving statistics to a file when the CLOSE message
is received?  I know I wouldn't be happy if it was left half-written and
unclosed :)

  --=- Ritchie Annand

(there's a -at and a -dot in my e-mail that shouldn't be there :)

Re:Form won't close immediately


Quote
Tore Ottinsen wrote:

> I have a modal form with an OK button. When this button is pressed, a
> long loop starts which draws pixels on the main form. Problem is, the
> dialog form won't close until the loop has finished. I have tried
> Application.ProcessMessages both before and inside the loop with no
> effect.

Do you possibly mean you would like the dialog to Hide while the loop is
running?

Other Threads