我正在研究一個程序,它應該列出所有文件和它的大小(現在...)。我創建了一個簡單的應用程序,它應該將數據寫入列表框。我試圖寫在兩列的數據(第一個應該是名稱,並在旁邊,在另一列,它的大小),但我不明白,我該如何做到這一點。 有人可以幫我嗎?如何創建多列Listbox?
在此先感謝!
kampi
更新:
我嘗試使用列表控件,但遺憾的是我不能。我可以成功地編譯我的應用程序,但我只能看到空矩形。有人知道我做錯了什麼嗎?
BOOL CGetFileListDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
LVITEM lvItem;
LVCOLUMN lvColumn;
int nCol;
lvColumn.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
lvColumn.fmt = LVCFMT_CENTER;
lvColumn.cx = 10;
lvColumn.pszText = _T("Filename");
ListView_InsertColumn(m_List, 0, &lvColumn);
ListView_SetItemText(m_List, 0, 0, _T("TEST"));
return TRUE; // return TRUE unless you set the focus to a control
}
嗨!非常感謝您的幫助!我忘了初始化常用控件。再次感謝! – kampi