How to Store Dynamically in the List Control of MFC in Visual Studio?

I am working on the dialog based applciation using MFC in visual studio 2010. I used the list control as report type to display . I managed to display some hardcoded data on that output window. Here is the code. what's wrong in the code

    void CuserspecificationDlg::OnAdd()     // This function add file by clicking on Add button
    {
// TODO: Add your control notification handler code here
CFileDialog ldFile(TRUE);
// Show the File Open dialog and capture the result
if (ldFile.DoModal() == IDOK)
    { 

     CStdioFile fileName;
  //TCHAR buf[100]; // it is declared in h file


       while(  fileName.ReadString(buf,99))
      {}
              fileName.Close();

}

     void CuserspecificationDlg::InsertItems()
    {
    //
list.cx = 100;
list.pszText   = "Project";      // this project is the column heading of the dialog
list.iSubItem = 2;
::SendMessage(hWnd  ,LVM_INSERTCOLUMN, 
    (WPARAM)1,(WPARAM)&list);

SetCell(hWnd,"1",0,0);
SetCell(hWnd,buf,0,1);    // these 1,G,X,X are the hardcoded entries. 
SetCell(hWnd,"G ",0,2);
SetCell(hWnd," X",0,3);

//----- //

}

How to display that buf? It doesnt work . buf is not diplaying the content from file properly. As some characters 1,G and X are visible in the output window but the buf statement doesnt show the characters properly. .. What's wrong in the code.

Answers


To add items to a list control, you first need to create a column:

LVCOLUMN lvCol;
lvCol.mask = LVCF_TEXT | LVCF_WIDTH;
lvCol.pszText = L"Column Header Text";
m_CListCtrl.InsertColumn(0, &lvCol);

// ...

You then insert items into the list control of struct type LVITEM

LVITEM item;
item.mask = LVIF_TEXT;
item.pszText = "Column Text";
item.iItem = numItem;      // Item number
item.iSubItem = 0;         // Sub item number (column number)
m_CListCtrl.InsertItem(&item);

Need Your Help

How can i run rethinkdb-dump/export in RethinkDB + Docker

docker rethinkdb

When running RethinkDB through Docker: http://dockerfile.github.io/#/rethinkdb, i would like to be able to export datas through "rethinkdb-dump or rethinkdb-export", however it throws me the follow...

Joomla - VirtueMart 1 or 2

joomla virtuemart

I am pretty new to Virtuemart and now I do have to set up my first Webshop for a Customer.