visual-c++ - 第二次通过循环调用 CButton::Create 时出现运行时检查失败 #0。问题是什么?
问题描述
运行此代码时,我在 Create 的第二次迭代中得到“运行时检查失败 #0”。
m_nBtnCnt = List.GetCount();
if (m_pButton = new CColorButton[m_nBtnCnt])
{
// create the buttons on the dialog bar
for (int i = 0; i < m_nBtnCnt; i++)
{
// get the button def from the list
BUTTONDEF Def;
List.Get(i, (void *)&Def);
// set up the window rectangle
CRect Rect(Def.nLeft, Def.nTop + nOff, Def.nLeft + 80, Def.nTop + 50 + nOff);
// set the window style
DWORD dwStyle = BS_PUSHBUTTON | BS_MULTILINE | BS_OWNERDRAW | WS_CHILD | WS_VISIBLE;
// create the button window on the dialog bar
m_pButton[i].Create(Def.szText, dwStyle, Rect, this, Def.nId);
m_pButton[i].SetFont(pFont);
m_pButton[i].SetColor(Def.crButton, Def.crText);
}
}
相同的代码存在于三个应用程序中,但我只在一个应用程序中得到错误,然后只有在它以调试模式构建时。代码在视图类的 OnCreate 中;此时不存在其他执行线程。我正在使用带有 MFC 的 VS 2017。如果代码是在发布模式下构建的,则它会毫无错误地执行。我对此感到很困惑;谁能指出我正确的方向?
解决方案
推荐阅读
- ios - 如何在 Swift 5 中强制更新 CoreData 代码文件(属性扩展)?
- bootloader - 无法为 PIC24FJ128GC006 的链接描述文件定义 __BOOTLOADER
- javascript - jquery如何进行多个ajax调用
- powershell - 将子文件夹名称导出为路径,并为不同位置的每个父子文件夹创建一个 csv
- pg-promise - 如何在 pg-promise 中将数组作为 rowMode="array" 的参数传递
- java - 如何使用存储访问框架在 android q 的 Downloads 中创建目录
- amazon-web-services - AWS Kubernetes 上的 JHipster Registry 不显示 Swagger API
- safari - 如何使用 ITP 在 Safari IFrame 中跟踪 OpenID Connect 的状态?
- azure-storage - 使用 AzCopy 将 ADLS 同步到 Azure 存储
- java - 如何将值从一个类的 onOptionsItemSelected 方法传递给另一个类