本文整理汇总了C++中CFileInfo::GetTypeName方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileInfo::GetTypeName方法的具体用法?C++ CFileInfo::GetTypeName怎么用?C++ CFileInfo::GetTypeName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileInfo
的用法示例。
在下文中一共展示了CFileInfo::GetTypeName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CalcMinColumnWidth
int CFileBrowserListCtrl::CalcMinColumnWidth(int Col)
{
enum {
BORDER = 6, // minimal spacing; less causes abbreviated text
SLACK = 3 // prevents widest item from touching right edge
};
CWaitCursor wc; // iterating all items can be slow, especially for file type
CClientDC dc(this);
HGDIOBJ PrevFont = dc.SelectObject(GetFont()); // must use list control's font
int width = 0;
CSize sz;
CFileInfo FileInfo;
CString str;
int items = m_DirList.GetCount();
for (int i = 0; i < items; i++) {
const CDirItem& item = m_DirList.GetItem(i);
switch (Col) {
case COL_NAME:
str = item.GetName();
break;
case COL_SIZE:
if (item.IsDir())
continue;
FormatSize(item.GetLength(), str);
break;
case COL_TYPE: // slow if we have many unique file types that aren't cached
m_FileInfoCache.GetFileInfo(GetFolder(), item, FileInfo);
str = FileInfo.GetTypeName();
break;
case COL_MODIFIED:
if (item.GetLastWrite() == 0)
continue;
FormatTime(item.GetLastWrite(), str);
break;
default:
ASSERT(0);
}
GetTextExtentPoint32(dc.m_hDC, str, str.GetLength(), &sz);
if (sz.cx > width)
width = sz.cx;
}
dc.SelectObject(PrevFont); // restore DC's previous font
// 25feb09: GetItemRect can fail e.g. if list is empty, in which case we
// must avoid adding garbage to column width
CRect IconRect;
if (GetItemRect(0, IconRect, LVIR_ICON))
width += IconRect.Width();
else // can't get item rect, fall back to system metrics
width += GetSystemMetrics(m_ViewType == VTP_ICON ? SM_CXICON : SM_CXSMICON);
width += BORDER + SLACK;
return(width);
}