I want my Dialog window destroyed because the
Initialization failed in InitDialog().. But just using
DestroyWindow() ends in an access violation..
Thanks
Hannes Gräuler <hangr....@gmx.de> schrieb in im Newsbeitrag:
9ibtrl$h7u$07$1...@news.t-online.com...
Actually, I'd be inclined to call CDialog::OnCancel, since you don't
call DestroyWindow on modal dialogs.
Note that saying "ends in an access violation" isn't terribly
informative; you should be running under the debugger and be able to
determine what was going on. But I think that calling DestroyWindow on
a modal dialog is the real cause here.
joe
Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www3.pgh.net/~newcomer
MVP Tips: http://www3.pgh.net/~newcomer/mvp_tips.htm
Jeff...
--
Please post all follow-ups to the newsgroup only.
"Joseph M. Newcomer" <newc...@flounder.com> wrote in message
news:q0csktcrt6rbpnbrm...@4ax.com...
On Thu, 12 Jul 2001 18:26:39 -0500, "Jeff Partch"
<airb...@airmail.net> wrote:
>Why not call EndDialog(-1) and return FALSE?
>
>Jeff...
Joseph M. Newcomer [MVP]
Jeff...
--
Please post all follow-ups to the newsgroup only.
"Joseph M. Newcomer" <newc...@flounder.com> wrote in message
news:m6u3lt8fvmcmq36co...@4ax.com...
On Sun, 15 Jul 2001 16:10:15 -0500, "Jeff Partch"
<airb...@airmail.net> wrote:
>Well I'll bite, Joe! I thought the calling EndDialog was a (possibly the) documented way to destroy
>a dialogbox during WM_INITDIALOG failure..."A dialog box procedure can call EndDialog at any time,
>even during the processing of the WM_INITDIALOG message. If your application calls the function
>while WM_INITDIALOG is being processed, the dialog box is destroyed before it is shown and before
>the input focus is set."...what would the superclass be doing that would invalidate this
>requirement?
>
>Jeff...
Joseph M. Newcomer [MVP]
Jeff...
"Joseph M. Newcomer" <newc...@flounder.com> wrote in message
news:qmgcltodtlhdbulv9...@4ax.com...
On Thu, 19 Jul 2001 04:30:49 -0500, "Jeff Partch"
Jeff...
"Joseph M. Newcomer" <newc...@flounder.com> wrote in message
news:42bnltcourcn8kacq...@4ax.com...
Raj
"Jeff Partch" <airb...@airmail.net> wrote in message
news:OI5Wdw0EBHA.1328@tkmsftngp07...
"Raj Kulkarni" <rajku...@gl.com> wrote in message news:eEb#$tgGBHA.1836@tkmsftngp03...
> The cases that are being talked about here seem to apply to destroying a
> modal dialog box. What I need to know is how to destroy a modeless dialog
> box from "OnInitDialog".
>
> Raj
>
>
Well, my answer is still EndDialog if we're talking about an MFC CDialog. The various overrides available in the modeless CDialog
creation all wind up in...
BOOL CWnd::CreateDlgIndirect(LPCDLGTEMPLATE lpDialogTemplate, CWnd* pParentWnd, HINSTANCE hInst)
...which specifically checks for the EndDialog call during WM_INITDIALOG processing...
...
// handle EndDialog calls during OnInitDialog
if (hWnd != NULL && !(m_nFlags & WF_CONTINUEMODAL))
{
::DestroyWindow(hWnd);
hWnd = NULL;
}
...
// help with error diagnosis (only if WM_INITDIALOG didn't EndDialog())
if (hWnd == NULL)
{
...
return FALSE;
...
Although, according to MSDN Article Q193099, "FIX: CDialog::Create() Returns Incorrect Value Calling EndDialog", there was a bug in
this code (that would cause these CDialog::CreateXXX variants to return a non-zero value) that was, "fixed in the Visual Studio 6.0
Service Pack 1".
HTH,