MFC编程中CImageList异常VS-2008
我正在关注一本名为(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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论