Answer the question
In order to leave comments, you need to log in
How to solve the problem of working with a dialog class in an MFC project?
MSVS 2010. There is a dialog application based on MFC. There is some controller class in which I want to store a pointer to the dialog object for subsequent interaction. But when you try to attach the dialog header file ( Project_nameDlg.h ) to the controller, the compiler starts swearing at all sorts of nonsense (that the define-constant IDD_PROJECT_NAME_DIALOG is not defined - the identifier of the dialog in resource.h, and there it swears that ";" is expected before the constants ).
Clearly: let there be a dialog class CProject_nameDlg and another class Test, with a pointer to the first one.
/* Project_nameDlg.h */
#pragma once
#include "afxwin.h"
class CProject_nameDlg : public CDialog {
public:
CProject_nameDlg(CWnd* pParent = NULL); // standard constructor
enum { IDD = IDD_PROJECT_NAME_DIALOG };
.......
};
/* Test.h */
#include "Project_nameDlg.h"
stuct Test {
CProject_nameDlg* ptr_;
Test(CProject_nameDlg* ptr) : ptr_( ptr ) { }
};
Answer the question
In order to leave comments, you need to log in
The problem was solved by a hard forced inclusion resource.h
in the dialog header file ( Project_nameDlg.h
). Because there are define constants, then there will be no collision (overridden), but I will be sure that I will not catch
undeclared identifier IDD_PROJECT_NAME_DIALOG
There is probably something wrong with the order of the includes (maybe even in the place where it says #include "Test.h").
Try adding at the beginning of Test.h :
#pragma once
#include "afxwin.h"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question