Hello guys i keep getting a
Unhandled exception at 0x7c177ac0 (mfc71d.dll) in LSMUtility.exe: 0xC0000005: Access violation reading location 0xcdcdcdbd.
However according to MSDN the code is right:
void CTemp::OnDelete()
{
// TODO: Add your control notification handler code here
CLSMUtilityDlg *main_dlg = (CLSMUtilityDlg *) GetParent();
if(pos != main_dlg->BTList.GetTailPosition())
{
main_dlg->BTList.RemoveAt(pos);
MessageBox("deleted");
}
}
the above code works and the error only occurs if itterate through the list by using Next and Back buttons and functions:
void CTemp::OnNext()
{
// TODO: Add your control notification handler code here
CLSMUtilityDlg *main_dlg = (CLSMUtilityDlg *) GetParent();
if(pos != main_dlg->BTList.GetTailPosition())
{
main_dlg->BTList.GetNext(pos);
Display();
}
else
MessageBox("end");
}
//and Pervious
void CTemp::OnPervious()
{
// TODO: Add your control notification handler code here
CLSMUtilityDlg *main_dlg = (CLSMUtilityDlg *) GetParent();
if(pos != main_dlg->BTList.GetHeadPosition())
{
main_dlg->BTList.GetPrev(pos);
Display();
}
else
MessageBox("At beginning");
}
Can anyone suggest where i've gone wrong please?
Thanks