BOOL NewDialg: : Create () { Return CDialog: : Create (IDD_DIALOG1 m_pview); } Compile error
Error C2664: 'BOOL CDialog: : Create (LPCTSTR, CWnd *)' : always convert parameter 1 from ' 'to' LPCTSTR '
Given CDialog
class CDialog: public CWnd { Public: Virtual BOOL Create (LPCTSTR lpszTemplateName, CWnd * pParentWnd=NULL); Virtual BOOL Create (UINT nIDTemplate, CWnd * pParentWnd=NULL); } Analysis of the reason is CDialog: : Create (IDD_DIALOG1 m_pview); Parameters of call was the first to Create, so wrong, but why don't you call the Create the second, I look at the others also wrote the code,
CodePudding user response:
The second the first parameter of the Create type UINT is unsigned integer alias
Typedef unsigned int UINT;
IDD_DIALOG1 is dialog ID
# define IDD_DIALOG1. 310
CodePudding user response:
Their top, trouble each great god to have a look
CodePudding user response:
It's been two hours,,,
CodePudding user response:
In the edit box to add dialog resources, ID is modified to IDD_DIALOG1, then your code can use, if have resources, the parameters of the functions of IDD_DIALOG1 replace existing resource ID
CodePudding user response:
reference 4 floor zgl7903 response: in the edit box to add dialog resources, ID is modified to IDD_DIALOG1, then your code can use, if you have resources, that the function parameters of IDD_DIALOG1 replace existing resource ID Have added the dialog resource and ID is IDD_DIALOG1 CodePudding user response:
I already despair,,, CodePudding user response:
NewDialg. CPP in # include "resource. H" try, may be ID has not been normal recognition CodePudding user response:
Return CDialog: : Create (MAKEINTRESOURCE (IDD_DIALOG1), m_pview); ? CodePudding user response:
BOOL CAboutDlg: : Create () { The CWnd * pview=0; Return CDialog: : Create (IDD_ABOUTBOX pview); } There is nothing wrong? CodePudding user response:
BOOL CAboutDlg: : Create () { The CWnd * pview=AfxGetMainWnd (); Return CDialog: : Create (IDD_ABOUTBOX pview); } There's nothing wrong with? CodePudding user response:
Can determine the compiler error is Return CDialog: : Create (IDD_DIALOG1 m_pview); This line? CodePudding user response:
A test, first of all, use the MAKEINTRESOURCE, the unit of the computer to compile, home computer not. A lot of data, then baidu type conversion of the visual studio is said to be more strict, the type will not default compatible, need to enforce type conversion, Return CDialog: : Create (LPCTSTR IDD_DIALOG1, (CWnd *) m_pview); At this time to compile, But Return CDialog: : Create ((UINT) IDD_DIALOG1, (CWnd *) m_pview); Or compiled not through, that is to say here or just call the first CDialog: : Create (), not call for a second, a great god answers, why not call the second? How can I call for a second? Extended another problem that MFC single document to the default view class CMFCStudyView in the client area click, calling a modal dialog box NewDialg, m_pdlg is CMFCStudyView private member function, no initialization, Why the trigger OnLButtonDown, direct access to the following m_pdlg - & gt; SetActiveWindow (); I did not create m_pdlg, so after the operation, direct crash, even in the constructor CMFCStudyView Initialized to NULL, as well as into m_pdlg - & gt; SetActiveWindow (); The last crash directly, Void CMFCStudyView: : OnLButtonDown (UINT nFlags, CPoint point) { If (m_pdlg!=NULL) M_pdlg - & gt; SetActiveWindow ();//click again, the activation dialog The else { M_pdlg=new NewDialg (this);//for the first time, click the create a modal dialog box M_pdlg - & gt; The Create (); } The CView: : OnLButtonDown (nFlags, point); } But create a modal dialog box can be directly run, why? Void CMFCStudyView: : OnLButtonDown (UINT nFlags, CPoint point) { M_pdlg=new NewDialg (this);//for the first time, click the create a modal dialog box M_pdlg - & gt; The Create (); The CView: : OnLButtonDown (nFlags, point); } CodePudding user response:
9, 10, floor is vc6, no compile wrong!