So, I am continuing to work through a tutorial and I have run into another 'undeclared identifier' error. I have checked that the definition exists in resource.h, but I still get the error. Again, it is a short tutorial, so here is the code:
#include <afxwin.h>
#include "resource.h"
#include "newdialog.h"
class MFC_Tutorial_Window :public CFrameWnd
{
CMenu menu1;
public:
MFC_Tutorial_Window()
{
Create(NULL,_T("MFC Tutorial Part 5 CoderSource Dialog"));
menu1.LoadMenu(IDR_MENU1);
SetMenu(&menu1);
}
void OnClickDialogNew();
DECLARE_MESSAGE_MAP()
};
BEGIN_MESSAGE_MAP( MFC_Tutorial_Window, CFrameWnd)
ON_COMMAND(ID_MYDIALOG,OnClickDialogNew)
END_MESSAGE_MAP()
void MFC_Tutorial_Window::OnClickDialogNew()
{
newdialog dlg;
dlg.DoModal();
}
class MyApp :public CWinApp
The compiler gives me the following error (it is the only error):
newdialog.h(15): error C2065: 'ID_MYDIALOG' : undeclared identifier
The error message brings me to
enum { IDD = ID_MYDIALOG };
which is line 15 from the following code.
<pre lang="cs">#pragma once
#include<afxwin.h>
class newdialog : public CDialog
{
DECLARE_DYNAMIC(newdialog)
public:
newdialog(CWnd* pParent = NULL);
virtual ~newdialog();
enum { IDD = ID_MYDIALOG };
protected:
virtual void DoDataExchange(CDataExchange* pDX);
DECLARE_MESSAGE_MAP()
};
Any suggestion on where I should look? Also, if there is a recommendation for a tutorial not written for VC6, but for VS2010 it would make things easier. However, I have been learning by my mistakes....
Ok, so I was able to fix the compiler issue by including resource.h (per advice) in the newdialog class...but now the dialog box doesn't show! I included a menu resource, but clicking on 'New' doesn't cause the dialog box to appear.