Article View: borland.public.cppbuilder.nativeapi
Article #16455Re: strange behavior of input dialog box - mrOk
From: JeJe
Date: Tue, 13 May 2003 17:00
Date: Tue, 13 May 2003 17:00
55 lines
2839 bytes
2839 bytes
you are right, actually I had this: frmInputDialog = new TfrmInputDialog(this); nResult = frmInputDialog->ShowModal(); delete frmInputDialog; ---------------- anyhow, I know this->Close() should not be in the OK button's OnClick() event, this is written by someone else long time ago. the thing that bothers me is that it used to work, and I don't get it why it should work in any way. do you see how it could have ever worked at one point? Thanks, Jerri "Remy Lebeau \(TeamB\)" <gambit47@yahoo.com> wrote: > >"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:
<3ec124b6@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<3ec08128$1@newsgroups.borland.com> <3ec08e40$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-13 10:06:46 PST From: "JeJe" <jejesan@hotmail.com> Sender: "JeJe" <jejesan@hotmail.com> Reply-To: "JeJe" <jejesan@hotmail.com> Subject: Re: strange behavior of input dialog box - mrOk Newsgroups: borland.public.cppbuilder.nativeapi X-User-Info: 65.207.116.227 65.207.116.227 References: <3ec08128$1@newsgroups.borland.com> <3ec08e40$1@newsgroups.borland.com> NNTP-Posting-Host: 207.105.83.65 Message-ID: <3ec124b6@newsgroups.borland.com> Date: 13 May 2003 10:00:38 -0700 X-Trace: newsgroups.borland.com 1052845238 207.105.83.65 (13 May 2003 10:00:38 -0700) Lines: 56 Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail