MFC编程中CImageList异常VS-2008

发布于 2024-12-10 02:02:40 字数 941 浏览 0 评论 0原文

我正在关注一本名为(Programming with Microsoft Visual C++ .NET, Sixth Edition)的 MFC 书籍的示例 8a。

然而,当我尝试编译它时,我遇到了以下异常:

Unhandled exception at 0x78a782ac (mfc90ud.dll) in Ex08a.exe:
0xC0000005: Access violation reading location 0x00000020.

它指向

{
    ASSERT(::IsWindow(m_hWnd));
    return CImageList::FromHandle((HIMAGELIST)::SendMessage(m_hWnd, LVM_SETIMAGELIST,
       nImageList, (LPARAM)pImageList->GetSafeHandle()));
}

afxcmn.inl

由于我使用的是 Visual Studio 2008,所以我的代码和 Book 的代码之间存在差异。

以下是其中一些差异:

ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST1, &CEx08aDialog::OnLvnItemChangedListview1)
ON_NOTIFY(TVN_SELCHANGED, IDC_TREEVIEW1, &CEx08aDialog::OnTvnSelchangedTreeview1)

static char* color[]={"white","black","red","blue","yellow","cyan","purple","green"};
pList->InsertItem(n,(LPCTSTR)color[n],n);

欢迎任何评论。

I'm following example 8a of a MFC book entitled (Programming with Microsoft Visual C++ .NET, Sixth Edition).

However when I tried to compile it I faced with the following exceptions:

Unhandled exception at 0x78a782ac (mfc90ud.dll) in Ex08a.exe:
0xC0000005: Access violation reading location 0x00000020.

which points to

{
    ASSERT(::IsWindow(m_hWnd));
    return CImageList::FromHandle((HIMAGELIST)::SendMessage(m_hWnd, LVM_SETIMAGELIST,
       nImageList, (LPARAM)pImageList->GetSafeHandle()));
}

in afxcmn.inl

Since I'm using visual studio 2008, there are differences between my code and Book's code.

The following lines are some of those discrepancies:

ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST1, &CEx08aDialog::OnLvnItemChangedListview1)
ON_NOTIFY(TVN_SELCHANGED, IDC_TREEVIEW1, &CEx08aDialog::OnTvnSelchangedTreeview1)

static char* color[]={"white","black","red","blue","yellow","cyan","purple","green"};
pList->InsertItem(n,(LPCTSTR)color[n],n);

Any comment is welcome.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文