开发者

Displaying the size of a file in CListCtrl

开发者 https://www.devze.com 2022-12-12 11:05 出处:网络
I am working in Windows MFC application..In my de开发者_开发问答sign am displaying the file details (type,name,size) in a CListCtrl control. I found those file details using FileStatus but when I try

I am working in Windows MFC application..In my de开发者_开发问答sign am displaying the file details (type,name,size) in a CListCtrl control. I found those file details using FileStatus but when I try to display, I am not able to display the file size since its an integer. I tried CListCtrl::SetItemText and I also tried to type cast but its not working.

int nIndex = m_ListCtrl.InsertItem(0, filename);
m_myList.SetItemText(nIndex, 0, fileSize);

m_myList is the CListCtrl variable. Can any one help me please?


Convert the integer to a string before you call SetItemText, also use sub item 1 if you want to add it to the second column.

CString strFileSize;
strFileSize.Format("%u", (unsigned)fileSize);

int nIndex = m_ListCtrl.InsertItem(0, filename);
m_myList.SetItemText(nIndex, 1, strFileSize);
0

精彩评论

暂无评论...
验证码 换一张
取 消