944,050 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 3783
  • C RSS
May 4th, 2006
0

MFC - CList RemoveAt() function

Expand Post »
Hello guys i keep getting a

Quote ...
Unhandled exception at 0x7c177ac0 (mfc71d.dll) in LSMUtility.exe: 0xC0000005: Access violation reading location 0xcdcdcdbd.
However according to MSDN the code is right:

  1. void CTemp::OnDelete()
  2. {
  3. // TODO: Add your control notification handler code here
  4. CLSMUtilityDlg *main_dlg = (CLSMUtilityDlg *) GetParent();
  5.  
  6. if(pos != main_dlg->BTList.GetTailPosition())
  7. {
  8. main_dlg->BTList.RemoveAt(pos);
  9. MessageBox("deleted");
  10. }
  11. }

the above code works and the error only occurs if itterate through the list by using Next and Back buttons and functions:

  1. void CTemp::OnNext()
  2. {
  3. // TODO: Add your control notification handler code here
  4. CLSMUtilityDlg *main_dlg = (CLSMUtilityDlg *) GetParent();
  5. if(pos != main_dlg->BTList.GetTailPosition())
  6. {
  7. main_dlg->BTList.GetNext(pos);
  8. Display();
  9. }
  10. else
  11. MessageBox("end");
  12. }
  13.  
  14. //and Pervious
  15.  
  16. void CTemp::OnPervious()
  17. {
  18. // TODO: Add your control notification handler code here
  19. CLSMUtilityDlg *main_dlg = (CLSMUtilityDlg *) GetParent();
  20. if(pos != main_dlg->BTList.GetHeadPosition())
  21. {
  22. main_dlg->BTList.GetPrev(pos);
  23. Display();
  24. }
  25. else
  26.  
  27. MessageBox("At beginning");
  28. }
Can anyone suggest where i've gone wrong please?

Thanks
Similar Threads
Reputation Points: 12
Solved Threads: 5
Posting Pro
Acidburn is offline Offline
510 posts
since Dec 2004
May 4th, 2006
0

Re: MFC - CList RemoveAt() function

Access violation reading location 0xcdcdcdbd.
Isn't that how uninitialized memory is filled in debug mode?
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004
May 4th, 2006
0

Re: MFC - CList RemoveAt() function

Quote originally posted by Dave Sinkula ...
Access violation reading location 0xcdcdcdbd.
Isn't that how uninitialized memory is filled in debug mode?
I think so, but I'm not sure how to fix it, it would appear that when i delete an object from the list, it gets deleted, but if i click pervious that works but then if i delete that and click 'next' i get that error.
Reputation Points: 12
Solved Threads: 5
Posting Pro
Acidburn is offline Offline
510 posts
since Dec 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: write apps for windows pda or palmOS pda in C?
Next Thread in C Forum Timeline: Please guide me in making an airlines database





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC