-1
我正在使用Visual Studio 2010中的MFC進行基於對話框的應用。我使用列表控件作爲報告類型來顯示。我設法在該輸出窗口上顯示一些硬編碼數據。這是代碼。什麼是錯的代碼如何在Visual Studio中的MFC列表控件中動態地存儲?
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);
// ----- //
}
如何顯示BUF?它不起作用。 buf沒有正確地從文件中提取內容。由於某些字符1,G和X在輸出窗口中可見,但buf語句不能正確顯示字符。 ..代碼中出現了什麼問題。
這件事情的列表控件我一直已經在我的原始程序中聲明。請正確地閱讀問題 – Nabeel 2012-07-17 15:36:21
@Nabeel:''這件事我已經宣佈「'。什麼東西」? 'item'是什麼類型?它當然沒有在你的代碼片段中聲明。上面的例子是添加項目到列表控件的基本方法。你需要擴展「它不起作用」。 – 2012-07-17 15:47:31
您發佈的答案;我已經在我原來的程序中聲明過,但沒有粘貼到這裏。我有SET CELL FUNCTIon的問題..我希望現在清楚 – Nabeel 2012-07-17 16:08:59