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. Problem with List Control in visual c++

Problem with List Control in visual c++

Scheduled Pinned Locked Moved C / C++ / MFC
c++help
3 Posts 2 Posters 1 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.
  • L Offline
    L Offline
    lolici
    wrote on last edited by
    #1

    Hi everyone! I have problem using list control in visual c++. I tried to create a table which appears on a dialog window but when I run the executable on dialog appears only an empty "window" without the data I wrote. I used the "report view". Here is the code:

    void CDataDialog::OnLvnItemchangedStoreItems(NMHDR *pNMHDR, LRESULT *pResult)
    {

    LPNMLISTVIEW pNMLV = reinterpret\_cast(pNMHDR);
    // TODO: Add your control notification handler code here
    \*pResult = 0;
    //SetIcon(m\_hIcon, TRUE);         // Set big icon
    //SetIcon(m\_hIcon, FALSE);         // Set small icon
    
    								 // TODO: Add extra initialization here
    								 // Ask Mfc to create/insert a column
    m\_StoreItems.InsertColumn(
    	0,              // Rank/order of item 
    	L"ID",          // Caption for this header 
    	LVCFMT\_LEFT,    // Relative position of items under header 
    	100);           // Width of items under header
    
    m\_StoreItems.InsertColumn(1, L"Resistivity", LVCFMT\_CENTER, 80);
    m\_StoreItems.InsertColumn(2, L"Permeability", LVCFMT\_LEFT, 100);
    m\_StoreItems.InsertColumn(3, L"Rdc", LVCFMT\_LEFT, 80);
    
    int nItem;
    
    nItem = m\_StoreItems.InsertItem(0, L"1");
    m\_StoreItems.SetItemText(nItem, 1, L"0.000869");
    m\_StoreItems.SetItemText(nItem, 2, L"1");
    m\_StoreItems.SetItemText(nItem, 3, L"0.09136");
    
    nItem = m\_StoreItems.InsertItem(0, L"2");
    m\_StoreItems.SetItemText(nItem, 1, L"0.0008603");
    m\_StoreItems.SetItemText(nItem, 2, L"1");
    m\_StoreItems.SetItemText(nItem, 3, L"0.09136");
    
    nItem = m\_StoreItems.InsertItem(0, L"3");
    m\_StoreItems.SetItemText(nItem, 1, L"0.000869");
    m\_StoreItems.SetItemText(nItem, 2, L"1");
    m\_StoreItems.SetItemText(nItem, 3, L"0.09136");
    //return TRUE;
    

    }

    void CInputView::OnLinefeaturesData()
    {
    // TODO: Add your command handler code here
    CInputDoc* pDoc = GetDocument();
    CDataDialog DialogWindow;
    DialogWindow.DoModal();

    }

    J 1 Reply Last reply
    0
    • L lolici

      Hi everyone! I have problem using list control in visual c++. I tried to create a table which appears on a dialog window but when I run the executable on dialog appears only an empty "window" without the data I wrote. I used the "report view". Here is the code:

      void CDataDialog::OnLvnItemchangedStoreItems(NMHDR *pNMHDR, LRESULT *pResult)
      {

      LPNMLISTVIEW pNMLV = reinterpret\_cast(pNMHDR);
      // TODO: Add your control notification handler code here
      \*pResult = 0;
      //SetIcon(m\_hIcon, TRUE);         // Set big icon
      //SetIcon(m\_hIcon, FALSE);         // Set small icon
      
      								 // TODO: Add extra initialization here
      								 // Ask Mfc to create/insert a column
      m\_StoreItems.InsertColumn(
      	0,              // Rank/order of item 
      	L"ID",          // Caption for this header 
      	LVCFMT\_LEFT,    // Relative position of items under header 
      	100);           // Width of items under header
      
      m\_StoreItems.InsertColumn(1, L"Resistivity", LVCFMT\_CENTER, 80);
      m\_StoreItems.InsertColumn(2, L"Permeability", LVCFMT\_LEFT, 100);
      m\_StoreItems.InsertColumn(3, L"Rdc", LVCFMT\_LEFT, 80);
      
      int nItem;
      
      nItem = m\_StoreItems.InsertItem(0, L"1");
      m\_StoreItems.SetItemText(nItem, 1, L"0.000869");
      m\_StoreItems.SetItemText(nItem, 2, L"1");
      m\_StoreItems.SetItemText(nItem, 3, L"0.09136");
      
      nItem = m\_StoreItems.InsertItem(0, L"2");
      m\_StoreItems.SetItemText(nItem, 1, L"0.0008603");
      m\_StoreItems.SetItemText(nItem, 2, L"1");
      m\_StoreItems.SetItemText(nItem, 3, L"0.09136");
      
      nItem = m\_StoreItems.InsertItem(0, L"3");
      m\_StoreItems.SetItemText(nItem, 1, L"0.000869");
      m\_StoreItems.SetItemText(nItem, 2, L"1");
      m\_StoreItems.SetItemText(nItem, 3, L"0.09136");
      //return TRUE;
      

      }

      void CInputView::OnLinefeaturesData()
      {
      // TODO: Add your command handler code here
      CInputDoc* pDoc = GetDocument();
      CDataDialog DialogWindow;
      DialogWindow.DoModal();

      }

      J Offline
      J Offline
      Jochen Arndt
      wrote on last edited by
      #2

      OnLvnItemchangedStoreItems seems to be a LVN_ITEMCHANGED notification code (Windows)[^] handler. That is called whenever an item of a list control is changed but you are trying to create columns and add items there. But that handler is never called while you are not adding and changing items (and will produce a stack overflow or dead lock when adding items from within the handler). Move the code from the handler to CDataDialog::OnInitDialog. That will populate the list and show it.

      L 1 Reply Last reply
      0
      • J Jochen Arndt

        OnLvnItemchangedStoreItems seems to be a LVN_ITEMCHANGED notification code (Windows)[^] handler. That is called whenever an item of a list control is changed but you are trying to create columns and add items there. But that handler is never called while you are not adding and changing items (and will produce a stack overflow or dead lock when adding items from within the handler). Move the code from the handler to CDataDialog::OnInitDialog. That will populate the list and show it.

        L Offline
        L Offline
        lolici
        wrote on last edited by
        #3

        Thank you very much sir!!It worked!!! :-D :)

        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