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 

ModalResult doesn't work perfectly!

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Using
View previous topic :: View next topic  
Author Message
Gerhard
Guest





PostPosted: Wed Jul 30, 2003 9:56 am    Post subject: ModalResult doesn't work perfectly! Reply with quote




hello,

in a dialog there is a button that is used for closing the dilaog,
its properties are:

Cancel = True
Caption = 'Cancel'
TabOrder = 1
ModalResult = mrNone

in the onclick handler, i just call Close; but in the following code,
the modal result is a non-zero(mrNone) value!

if ShowModal <> 0 then
....

as you see its modalresult is set to mrNone but when the user presses
the cancel button, the if statement will be executed!

i debugged the code, the result shows that when this button is clicked,
the modal result is set to 2!!

can anybody tell me what is the problem and what should i do to get rid
of it?

any comments would be appreciated,
Gerhard
Back to top
Eric ten Westenend
Guest





PostPosted: Wed Jul 30, 2003 10:22 am    Post subject: Re: ModalResult doesn't work perfectly! Reply with quote



Hello Gerhard,

The help file says with mrNone: Used as a default value before the user
exits.
So BEFORE the users exits. mrNone can never be the value of the modalresult
coming from modal form
You see this happen in the TCustomForm class in the Close method which is
called by your call to close

procedure TCustomForm.Close;
var
CloseAction: TCloseAction;
begin
if fsModal in FFormState then
ModalResult := mrCancel
..
..
..

Set the ModalResult property for the button to mrCancel and don't call
CLOSE yourself will do the job.
The form is closes, the modalresult <> 0


Eric

"Gerhard" <no (AT) spam (DOT) com> schreef in bericht
news:3f27963d$1 (AT) newsgroups (DOT) borland.com...
Quote:

hello,

in a dialog there is a button that is used for closing the dilaog,
its properties are:

Cancel = True
Caption = 'Cancel'
TabOrder = 1
ModalResult = mrNone

in the onclick handler, i just call Close; but in the following code,
the modal result is a non-zero(mrNone) value!

if ShowModal <> 0 then
....

as you see its modalresult is set to mrNone but when the user presses
the cancel button, the if statement will be executed!

i debugged the code, the result shows that when this button is clicked,
the modal result is set to 2!!

can anybody tell me what is the problem and what should i do to get rid
of it?

any comments would be appreciated,
Gerhard




Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Using 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.