BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Modal Form not closing after ModalResult is set

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage)
View previous topic :: View next topic  
Author Message
Brian
Guest





PostPosted: Mon May 08, 2006 8:14 pm    Post subject: Modal Form not closing after ModalResult is set Reply with 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;
}
Back to top
Danzer
Guest





PostPosted: Mon May 08, 2006 9:14 pm    Post subject: Re: Modal Form not closing after ModalResult is set Reply with quote



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





PostPosted: Mon May 08, 2006 11:14 pm    Post subject: Re: Modal Form not closing after ModalResult is set Reply with quote



"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





PostPosted: Mon May 08, 2006 11:14 pm    Post subject: Re: Modal Form not closing after ModalResult is set Reply with quote

"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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.