如何从 MFC 中的对话框头文件访问静态变量
How to access static variable from Dialog header file in MFC
CDialog我在CDialogDlg.h
中有static int mStatus;
。我喜欢从另一个cpp file
访问该静态变量,例如 test.cpp
。通常我们访问静态变量CDialogDlg::mStatus = 1.
但是当我CDialogDlg.h
包含在test.h
中时,我得到了两个编译错误
Error 1: error C2504: 'CDialogEx' : base class undefined
Error 2: error C2065: 'IDD_CDialog_DIALOG' : undeclared identifier
为什么我不能将CDialogDlg.h
包含在test.h
中.我对MFC不是很熟悉。谢谢。
由于默认情况下#include "resource.h"
通常包含在头文件中,因此CMyNameApp.h
它应该已#include <afxdialogex.h>
。即使您可以从标头中删除#include "resource.h"
,也必须再次包含它。
#include "resource.h"
#include <afxdialogex.h>
应该解决你的整个问题。
相关文章:
- 防止临时对象文件访问 MSVC 中的磁盘
- 内存映射文件访问非常慢
- 从多个文件访问静态全局 WinForm UI 对象
- 在单元测试项目中包括 .c 文件,并从多个 cpp 文件访问它而不会出现链接问题
- 如何在Android中从本机编译的c ++二进制文件访问相机
- 如何:监视Windows中另一个进程的文件访问?
- 如何从NTFS中的$ MFT文件访问文件的每个块的文件指针
- 执行C 代码时快速频繁的文件访问
- 使用TDD时隐藏文件访问实现详细信息
- 从C文件访问C 类成员功能
- 从另一个CPP文件访问Form1的文本框,Visual C 2010
- 在所有CPP文件中使用一个Globe变量.如果CPP文件的一个类更改该值,我想从另一个类CPP文件访问它
- 如何从C 文件访问$(target_arch)
- 系统访问出界异常,尝试从flatbuffer的二进制文件访问"LengthofTable"
- 如何声明可通过多个头文件访问的对象
- 使用二进制文件访问违规读取位置
- 哪种类型的文件访问使用
- 在其他源文件中没有通用的头文件访问功能
- 文件访问不起作用
- Windows 8 应用商店应用程序C++文件访问