Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. error in displaying in listbox

error in displaying in listbox

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++testingbeta-testing
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    danag
    wrote on last edited by
    #1

    I am trying to display the records in the listbox. When I try to Initialize the listbox with the value in *View.cpp, I am getting an 'Access violation'. Can someone help fixing it. here is the code: void CListdatabaseView::OnLButtonDblClk(UINT nFlags, CPoint point) { ... ... ... CListBox *plistb = (CListBox *) GetDlgItem(IDC_LIST1); CString str1; str1.Format("%s","TESTING"); plistb->AddString(str1); ddlg.DoModal(); }

    A L 2 Replies Last reply
    0
    • D danag

      I am trying to display the records in the listbox. When I try to Initialize the listbox with the value in *View.cpp, I am getting an 'Access violation'. Can someone help fixing it. here is the code: void CListdatabaseView::OnLButtonDblClk(UINT nFlags, CPoint point) { ... ... ... CListBox *plistb = (CListBox *) GetDlgItem(IDC_LIST1); CString str1; str1.Format("%s","TESTING"); plistb->AddString(str1); ddlg.DoModal(); }

      A Offline
      A Offline
      Anonymous
      wrote on last edited by
      #2

      without more to go on, i would say that the most likely problem is that 'plistb' is NULL and therefore plistb->AddString() is invalid. add ASSERT (plistb); after the call to GetDlgItem() to test it.

      D 1 Reply Last reply
      0
      • A Anonymous

        without more to go on, i would say that the most likely problem is that 'plistb' is NULL and therefore plistb->AddString() is invalid. add ASSERT (plistb); after the call to GetDlgItem() to test it.

        D Offline
        D Offline
        danag
        wrote on last edited by
        #3

        Adding ASSERT(plistb) doesnot solve the problem. Still get the same error.

        1 Reply Last reply
        0
        • D danag

          I am trying to display the records in the listbox. When I try to Initialize the listbox with the value in *View.cpp, I am getting an 'Access violation'. Can someone help fixing it. here is the code: void CListdatabaseView::OnLButtonDblClk(UINT nFlags, CPoint point) { ... ... ... CListBox *plistb = (CListBox *) GetDlgItem(IDC_LIST1); CString str1; str1.Format("%s","TESTING"); plistb->AddString(str1); ddlg.DoModal(); }

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          I'm having the same problem. Please let me know if you have found a solution. It's mostly related to trying to add data to a listbox which is not visible to current class. Try adding the data from the CListBox's owner class and it should work. Try it from an outside class it throws an ASSERT. Let me know please.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups