Article View: borland.public.cppbuilder.nativeapi
Article #16436Re: strange behavior of input dialog box - mrOk
From: Remy Lebeau (TeamB)
Date: Tue, 13 May 2003 06:20
Date: Tue, 13 May 2003 06:20
36 lines
2296 bytes
2296 bytes
"JeJe" <jejesan@hotmail.com> wrote in message
news:3ec08128$1@newsgroups.borland.com...
> inputDialogBox d = new frmInputDialogBox();
> nResult = d.ShowModal();
> ..
> delte d;
You can't use forms on the stack like that, you need to use a pointer
instead:
inputDialogBox *d = new frmInputDialogBox();
nResult = d->ShowModal();
...
delete d;
> the strange thing is, I don't think this should work, after
> calling this->Close() on clicking the OK button, the
> ModalResult will be reset to 2 (mrCancel) instead of the
> original value (mrOk), so on the frmInsert, the nResult will
> always be 2.
That is because Close() sets ModalResult to mrCancel internally. You should
not be calling Close() for a modal form in the first place. If your OnClick
handler for the Ok button doesn't do anything else, then don't assign an
OnClick handler at all. Just set its ModalResult property to mrOk at
design-time and leave it at that. At runtime, when you click the button, it
will automatically assign the form's ModalResult property to the same value
as its own ModalResult property, and the form will close automatically. If
you need to use an OnClick handler for extra processing, then you must leave
the button's ModalResult property to mrNone and then set the form's
ModalResult property manually.
Gambit
Technical Details
Message-ID:
<3ec08e40$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-09!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<3ec08128$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,f62c21c9818eccf7 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-05-12 23:27:02 PST From: "Remy Lebeau \(TeamB\)" <gambit47@yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3ec08128$1@newsgroups.borland.com> Subject: Re: strange behavior of input dialog box - mrOk Date: Mon, 12 May 2003 23:20:47 -0700 Lines: 38 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 207.175.226.26 Message-ID: <3ec08e40$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1052806720 207.175.226.26 (12 May 2003 23:18:40 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-09!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail