CDlgIDirectoryObject::CDlgIDirectoryObject(LPUNKNOWN pUnk, CWnd* pParent /*=NULL*/) : CDialog(CDlgIDirectoryObject::IDD, pParent) { //{{AFX_DATA_INIT(CDlgIDirectoryObject) m_sDN = _T(""); m_sRDN = _T(""); m_sSchema = _T(""); m_sClass = _T(""); m_sParent = _T(""); m_sAttributes = _T(""); //}}AFX_DATA_INIT HRESULT hr; m_pDirObject = NULL; hr = pUnk->QueryInterface( IID_IDirectoryObject, (void **) &m_pDirObject ); if ( !SUCCEEDED(hr) ) { AfxMessageBox(_T("Fatal Error! QI for IDirectoryObject failed")); return; } pUnk->Release(); ShowAttributes(); }
void DirectoryViewer::ShowEntry(const FileList::FileEntry& fileEntry, const ConfigFile& configFile, unsigned int columnNumber, unsigned int numColumns) { unsigned char color = static_cast<unsigned char>(configFile.GetColorByExtension(fileEntry.Extension())); color += color < 10 ? '0' : 'a' - 10; unsigned int columnWidth = m_console.Width() / numColumns; if (columnWidth > 89) { m_console.Printf("^4³"); // 1 ShowDate(fileEntry.m_time, false); // 11 ShowTime(fileEntry.m_time, false); // 9 ShowAttributes(fileEntry.m_attributes); // 6 m_console.Printf(" "); // 1 ShowSize(fileEntry.m_size, fileEntry.m_attributes, false); // 16 int remainingSpace = columnWidth - 1 - 11 - 9 - 6 - 1 - 16 - 1; m_console.Printf("^%c%-*s^7", color, remainingSpace, fileEntry.m_name.c_str()); } else if (columnWidth > 80) { m_console.Printf("^4³"); // 1 ShowDate(fileEntry.m_time, false); // 11 ShowTime(fileEntry.m_time, false); // 9 ShowAttributes(fileEntry.m_attributes); // 6 m_console.Printf(" "); // 1 ShowSize(fileEntry.m_size, fileEntry.m_attributes, true); // 7 m_console.Printf("^%c%-44.44s^7", color, fileEntry.m_name.c_str()); // 44 } else if (columnWidth > 40) { m_console.Printf("^4³"); // 1 ShowDate(fileEntry.m_time, true); // 9 ShowTime(fileEntry.m_time, true); // 6 ShowSize(fileEntry.m_size, fileEntry.m_attributes, true); // 7 m_console.Printf("^%c%-17.17s^7", color, fileEntry.m_name.c_str()); // 17 } else if (columnWidth > 26) { m_console.Printf("^4³"); // 1 ShowAttributes(fileEntry.m_attributes); // 6 ShowSize(fileEntry.m_size, fileEntry.m_attributes, true); // 7 m_console.Printf("^%c%-12.12s", color, fileEntry.m_name.c_str()); // 12 if (columnNumber + 1 == numColumns) m_console.Printf("^4³"); // 1 } else if (columnWidth > 20) { m_console.Printf("^4³"); // 1 ShowSize(fileEntry.m_size, fileEntry.m_attributes, true); // 7 m_console.Printf("^%c%-12.12s", color, fileEntry.m_name.c_str()); // 12 } else if (columnWidth > 16) { m_console.Printf("^4³^%c%-15.15s", color, fileEntry.m_name.c_str()); } else if (columnWidth > 13) { m_console.Printf("^4³^%c%-12.12s^7", color, fileEntry.m_name.c_str()); if (columnNumber + 1 == numColumns) m_console.Printf("^4³"); } if (columnNumber + 1 == numColumns) m_console.Printf("\n"); }