Home > Software engineering >  Please expert help (with doModal function creates the error dialog box problem)
Please expert help (with doModal function creates the error dialog box problem)

Time:10-04

In view of the single document. The response of the CPP to write menu, content is to create a dialog box, found in the debugging, always DoMadal error in this step, ask ace to give directions!
The specific error code is as follows:
 void CMFCApplication12View: : OnSet () 
{
//TODO: add the command handler code
Shezhidialog SZDLG;//shezhidialog is my definition dialog class
SZDLG. DoModal ();
}

I used to try to use the create to do it, or in the same position error, however,
Error message:

CodePudding user response:

The whole View. CPP is as follows:
//MFCApplication12View. CPP: CMFCApplication12View class the implementation of the 
//

# include "stdafx. H"
//SHARED_HANDLERS can achieve in the preview, thumbnails and search filter handle
//ATL project are defined, and allow the code to share with the project document,
# # ifndef SHARED_HANDLERS
# include "MFCApplication12. H"
# endif

# include "MFCApplication12Doc. H"
# include "MFCApplication12View. H"

# include "leiqudialog. H"
# include "shezhidialog. H"

# ifdef _DEBUG
# define new DEBUG_NEW
# endif


//CMFCApplication12View

IMPLEMENT_DYNCREATE (CMFCApplication12View, CView)

BEGIN_MESSAGE_MAP (CMFCApplication12View, CView)
//standard print command
ON_COMMAND (ID_FILE_PRINT, & amp; The CView: : OnFilePrint)
ON_COMMAND (ID_FILE_PRINT_DIRECT, & amp; The CView: : OnFilePrint)
ON_COMMAND (ID_FILE_PRINT_PREVIEW, & amp; The CView: : OnFilePrintPreview)
//ON_COMMAND (IDR_MENU_POP, & amp; The CView: : OnOperShow)//message response
ON_WM_RBUTTONDOWN ()
ON_COMMAND (ID_RESTART, & amp; CMFCApplication12View: : OnRestart)
ON_COMMAND (ID_SET, & amp; CMFCApplication12View: : OnSet)
END_MESSAGE_MAP ()

//int hang=9, lie=9, leishu=10;

//CMFCApplication12View structure/destructor

CMFCApplication12View: : CMFCApplication12View ()
{
//TODO: add construction code here
M_PopMenu. LoadMenu (IDR_MENU_POP);//create and load the menu resource
//gamedlg=new leiqudialog;
//SZDLG=new shezhidialog;
//leiqudialog gamedlg;
//gamedlg. Create (IDD_DIALOG1);
}

CMFCApplication12View: : ~ CMFCApplication12View ()
{
M_PopMenu. DestroyMenu ();//release the menu resource
//delete gamedlg;
//delete SZDLG;
}

BOOL CMFCApplication12View: : PreCreateWindow (CREATESTRUCT& Cs)
{
//TODO: here by modifying the
//cs to modify the CREATESTRUCT window class or style

Return the CView: : PreCreateWindow (cs);
}

//CMFCApplication12View map

Void CMFCApplication12View: : ontouch pDC (CDC */* */)
{
CMFCApplication12Doc * pDoc=GetDocument ();
ASSERT_VALID (pDoc);
if (! PDoc)
return;

//TODO: here is the machine data add rendering code
}


//print CMFCApplication12View

BOOL CMFCApplication12View: : OnPreparePrinting (CPrintInfo * pInfo)
{
//the default to
Return DoPreparePrinting (pInfo);
}

Void CMFCApplication12View: : OnBeginPrinting (CDC, pDC */* */pInfo CPrintInfo */* */)
{
//TODO: add additional print before initialization process
}

Void CMFCApplication12View: : OnEndPrinting (CDC, pDC */* */pInfo CPrintInfo */* */)
{
//TODO: add print after the cleaning process of
}


//CMFCApplication12View diagnosis

# ifdef _DEBUG
Void CMFCApplication12View: : AssertValid (const)
{
The CView: : AssertValid ();
}

Void CMFCApplication12View: : Dump (CDumpContext& Dc) const
{
The CView: : Dump (dc);
}

Const CMFCApplication12Doc * CMFCApplication12View: : GetDocument ()//a debug version is inline
{
ASSERT (m_pDocument - & gt; IsKindOf (RUNTIME_CLASS (CMFCApplication12Doc)));
Return (CMFCApplication12Doc *) m_pDocument;
}
# endif//_DEBUG


//CMFCApplication12View message handler


Void CMFCApplication12View: : OnRButtonDown (UINT nFlags, CPoint point)
{
//TODO: add the message handler code and/or invoke the default

M_pPop=m_PopMenu. GetSubMenu (0);//get the first child menu

ClientToScreen (& amp; Point);//convert coordinates by the client coordinates to screen coordinates
M_pPop - & gt; TrackPopupMenu (TPM_LEFTALIGN, point x, point y, this);
//display the Pop - up menu

The CView: : OnRButtonDown (nFlags, point);
}

//leiqudialog gamedlg;
Int cishu=0;

Void CMFCApplication12View: : OnRestart ()
{
//TODO: add the command handler code

//delete gamedlg;
//gamedlg=new leiqudialog;

Leiqudialog gamedlg;
Gamedlg. DoModal ();

//cishu++;
//gamedlg - & gt; Create (IDD_DIALOG1);
//gamedlg - & gt; ShowWindow (SW_SHOW);
//gamedlg - & gt; DestroyWindow ();
//delete gamedlg;
//Invalidate ();

}


Void CMFCApplication12View: : OnSet ()
{
//TODO: add the command handler code
//delete SZDLG;
Shezhidialog SZDLG;
SZDLG. DoModal ();
//SZDLG DestroyWindow ();
//SZDLG=new shezhidialog;
//SZDLG - & gt; Create (IDD_DIALOG3);
//SZDLG - & gt; ShowWindow (SW_SHOW);


Invalidate ().
}

CodePudding user response:

In OnInitDialog dialog and see whether there is something wrong with the initialization

CodePudding user response:

This question basic dialog box internal control is an object handle is invalid,

CodePudding user response:

Just met a few days ago, check the control's ID

CodePudding user response:

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related