模拟WINCE打开对话框,显示路径时,用缩进的方式显示(m_StaticCatalog是一个标签的变量)
/// 在界面上显示当前目录信息 void C_FileDialog::DisplayCatalogInterface( CString csPathInfo ) { // 当前显示根目录 if ( csPathInfo.GetLength()<=1 ) { m_StaticCatalog.SetWindowText(_T("My Devie")); return; } // 判断状态条能否显示开,如果不能,将上上个文件夹省略显示 CSize size; CRect rtCatalog; CDC *pDc= m_StaticCatalog.GetDC(); CFont *oldFont= pDc->SelectObject( m_StaticCatalog.GetFont()); size= pDc->GetTextExtent(csPathInfo); pDc->SelectObject(oldFont); m_StaticCatalog.ReleaseDC(pDc); m_StaticCatalog.GetClientRect(&rtCatalog); int m=rtCatalog.Width(); if ( size.cx<=rtCatalog.Width() ) { // 可以显示开 m_StaticCatalog.SetWindowText(csPathInfo); return; } else { // 显示不开,用省略号显示 CString csUpPath= GetFilePathUpPath( csPathInfo ); // 上上层路径+...+名字 csUpPath= GetFilePathUpPath(csUpPath)+ _T("...//") + m_CommonTool.GetFileName(csPathInfo); DisplayCatalogInterface( csUpPath ); return ; } }