 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Brian Guest
|
Posted: Mon May 08, 2006 8:14 pm Post subject: Modal Form not closing after ModalResult is set |
|
|
This is probably something I'm doing wrong, but here goes:
I have an application that performs some time consuming processing based on drag and drop operations. I bring up a
modal dialog that says something like "please wait..." and in
the FormShow() method, I begin my processing. After processing,
I set ModalResult to mrOk, but the form does not close. Any
ideas??
void __fastcall TForm2::FormShow(TObject *Sender)
{
ProcessFiles();
}
void __fastcall TForm2::ProcessFiles(void)
{ ...
...
ModalResult=mrOk;
} |
|
| Back to top |
|
 |
Danzer Guest
|
Posted: Mon May 08, 2006 9:14 pm Post subject: Re: Modal Form not closing after ModalResult is set |
|
|
Brian wrote:
| Quote: | This is probably something I'm doing wrong, but here goes:
I have an application that performs some time consuming processing based on drag and drop operations. I bring up a
modal dialog that says something like "please wait..." and in
the FormShow() method, I begin my processing. After processing,
I set ModalResult to mrOk, but the form does not close. Any
ideas??
void __fastcall TForm2::FormShow(TObject *Sender)
{
ProcessFiles();
}
void __fastcall TForm2::ProcessFiles(void)
{ ...
...
ModalResult=mrOk;
}
|
Replace
ModalResult=mrOk;
with
PostMessage(Handle,WM_CLOSE,0,0);
will close the modal dialog.
Danzer |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Mon May 08, 2006 11:14 pm Post subject: Re: Modal Form not closing after ModalResult is set |
|
|
"Brian" <brian (AT) nospam (DOT) org> wrote in message
news:445f9fbd$1 (AT) newsgroups (DOT) borland.com...
| Quote: | I bring up a modal dialog that says something like "please wait..." and
in the FormShow() method, I begin my processing. After processing,
I set ModalResult to mrOk, but the form does not close. Any
ideas??
|
You can't set the ModalResult property in the OnShow event. The property is
reset back to 0 after the OnShow event handler has exited, before the form
then begins tracking the property value. You need to delay your processing
until after the OnShow event has been triggered. Besides, the form is not
actually physically visible onscreen when the OnShow event is triggered
anyway. You can have the OnShow event start a short timer, or post a custom
message back to the form. When the timer elapses, or the message is
received, then begin your actual processing.
Gambit |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Mon May 08, 2006 11:14 pm Post subject: Re: Modal Form not closing after ModalResult is set |
|
|
"Danzer" <danzer (AT) REMOVEknology (DOT) net> wrote in message
news:445fa85a (AT) newsgroups (DOT) borland.com...
| Quote: | Replace
ModalResult=mrOk;
with
PostMessage(Handle,WM_CLOSE,0,0);
will close the modal dialog.
|
Keep in mind that doing so will change the ModalResult to mrCancel when the
form actually closes, since WM_CLOSE will call the form's Close() method,
which cancels modality.
Gambit |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|