-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