在 CDialog 派生类上创建使用 VS2015 CLR 返回 0,在 VC++ 6 中工作正常
Create on a CDialog derived class returns 0 with VS2015 CLR, worked fine in VC++ 6
我正在尝试迁移基于 VC++ 6 的代码以使用 VS2015 CLR。我的主要功能在工作,但 UI 缺少一些东西。
我已经将此问题追溯到由于父 CWnd 的空 HWnd 而导致的 SubclassDlgItem 失败。它是 NULL,因为在 CDialog 派生的父类上创建在 dlgcore 中返回 0 .cpp
if (hWnd != NULL && !(m_nFlags & WF_CONTINUEMODAL))
{
::DestroyWindow(hWnd);
hWnd = NULL;
}
m_nFlags = 256(定义为 #define WF_OLECTLCONTAINER 0x0100//某个后代是 afxwin.h 中的 OLE 控件)
hWnd 不是 NULL,但 '::CreateDialogIndirect() 没有创建窗口(即由于模板中的错误)并根据Microsoft注释返回 NULL'
以下是父 CWnd 的代码
CreateEx(
WS_EX_NOPARENTNOTIFY,
NULL,
"MainClient",
WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
0, 0, // Locate at upper left corner of client area
1, 1, // Initial size doesn't matter - will be sized to fit parent
parent->GetSafeHwnd(),
NULL
);
以下是创建 CDialog 的代码
m_pMainDialog = new CxMainDialog();
m_pMainDialog->Create(IDD_MAIN_DIALOG, this);
下面是 CxMainDialog 构造函数
CxMainDialog::CxMainDialog(CWnd* pParent /*=NULL*/)
: CDialog(CxMainDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CxMainDialog)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
我怎样才能让它工作?
此问题已通过在创建时删除导致问题的 ActiveX 控件来修复对话框模板来解决。我创建了一个重复的对话框并将其清空以测试创建是否成功。
相关文章:
- QSqlquery prepare()和bindvalue()不工作
- 导入库可以跨dll版本工作吗
- 以螺旋方式打印矩阵的程序.(工作不好)
- 对象指针在c++中是如何工作的
- 为什么在Windows上的VS 2019和Clang 9中"size_t"在没有标题的情况下工作
- VSOMEIP-2个设备之间的通信(TCP/UDP)不工作
- 为字符串中每 N 个字符插入空格的函数没有按照我认为的方式工作?
- C++为线程工作动态地分割例程
- 为什么我的 std::ref 无法按预期工作?
- 布尔比较运算符是如何在C++中工作的
- 参考资源文件VC++中的$(SolutionDir)
- SampleConsensusPrerejective(ext.RANSAC)是如何真正工作的
- VC++本机单元测试,找不到调试符号
- 不确定要在我的main中放入什么才能使我的代码正常工作
- CButton派生的'SubclassDlgItem'在VS2015 CLR的CDialogBar上不可见,但响应按钮点击,在VC++ 6中工作正常
- 在 CDialog 派生类上创建使用 VS2015 CLR 返回 0,在 VC++ 6 中工作正常
- SQL SP在SSMS中正常工作,但在VC++应用程序中失败
- Getting Random.h(使用unistd.h)在VC++上工作
- Cstring 在 VS 2012 中不起作用,但如果使用 VS 2012 打开 VC++ 6.0 项目,则可以工作
- 模板化代码在 G++ 下工作正常,但在 VC++ 下出错