DriverBar.cpp
资源名称:视频会议系统.rar [点击查看]
上传用户:popouu88
上传日期:2013-02-11
资源大小:2894k
文件大小:4k
源码类别:
IP电话/视频会议
开发平台:
Visual C++
- // DriverBar.cpp : implementation file
- //
- #include "stdafx.h"
- #include "File.h"
- #include "DriverBar.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CDriverBar
- CDriverBar::CDriverBar()
- {
- }
- CDriverBar::~CDriverBar()
- {
- }
- BEGIN_MESSAGE_MAP(CDriverBar, CSizingControlBar)
- //{{AFX_MSG_MAP(CDriverBar)
- //}}AFX_MSG_MAP
- ON_NOTIFY( TVN_ITEMEXPANDING , IDC_TREE , OnItemexpandingTree )
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CDriverBar message handlers
- BOOL CDriverBar::Create( CFrameWnd * pParentWnd )
- {
- if( CSizingControlBar::Create( "资源管理器" , pParentWnd , CSize( 230 , 260 ) , TRUE , 1 ) )
- {
- this->SetBarStyle( this->GetBarStyle( ) | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC );
- this->EnableDocking( CBRS_ALIGN_LEFT );
- this->SetSCBStyle( SCBS_SIZECHILD );
- pParentWnd->EnableDocking( CBRS_ALIGN_ANY );
- pParentWnd->DockControlBar( this , AFX_IDW_DOCKBAR_LEFT );
- this->m_tree.Create( WS_CHILD | WS_VISIBLE | TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_TRACKSELECT | TVS_INFOTIP | TVS_FULLROWSELECT | WS_BORDER | WS_TABSTOP , CRect( 0 , 0 , 1 , 1 ) , this , IDC_TREE );
- //设定系统图标
- SHFILEINFO shFinfo;
- HIMAGELIST imglist = ( HIMAGELIST )SHGetFileInfo( "C:\" , 0 , &shFinfo , sizeof( shFinfo ) , SHGFI_SYSICONINDEX | SHGFI_SMALLICON );
- this->m_tree.SendMessage( TVM_SETIMAGELIST , (WPARAM )TVSIL_NORMAL , ( LPARAM )imglist );
- this->Init( );
- // ScrollBar( this->m_tree.GetSafeHwnd( ) );
- return TRUE;
- }
- return FALSE;
- }
- void CDriverBar::Init( void )
- {
- char drivers[ MAX_PATH ];
- ::GetLogicalDriveStrings( MAX_PATH , drivers );
- char * now = drivers;
- int n , s;
- SHFILEINFO shFinfo;
- CFileFind find;
- while( strlen( now ) )
- {
- SHGetFileInfo( now , 0 , &shFinfo , sizeof( shFinfo ) , SHGFI_SYSICONINDEX | SHGFI_SMALLICON );
- n = shFinfo.iIcon;
- SHGetFileInfo( now , 0 , &shFinfo , sizeof( shFinfo ) , SHGFI_SYSICONINDEX | SHGFI_OPENICON | SHGFI_DISPLAYNAME );
- s = shFinfo.iIcon;
- HTREEITEM h = this->m_tree.InsertItem( shFinfo.szDisplayName , n , s );
- if( find.FindFile( ( CString )now + "*.*" ) )
- this->m_tree.InsertItem( "" , -1 , -1 , h );
- now += strlen( now ) + 1;
- }
- }
- void CDriverBar::Expand( void )
- {
- CPoint pt;
- ::GetCursorPos( &pt );
- this->m_tree.ScreenToClient( &pt );
- UINT flag;
- HTREEITEM item = this->m_tree.HitTest( pt , &flag );
- if( item )
- {
- HTREEITEM h = this->m_tree.GetChildItem( item );
- if( h )
- this->m_tree.DeleteItem( h );
- CString path;
- this->GetFullPath( path , item );
- if( path.IsEmpty( ) )
- return;
- int n , s;
- SHFILEINFO shFinfo;
- CFileFind find;
- if( ! find.FindFile( path + "\*.*" ) )
- return;
- while( find.FindNextFile( ) )
- {
- if( find.IsDots( ) )
- continue;
- SHGetFileInfo( find.GetFilePath( ) , 0 , &shFinfo , sizeof( shFinfo ) , SHGFI_SYSICONINDEX | SHGFI_SMALLICON );
- n = shFinfo.iIcon;
- SHGetFileInfo( find.GetFilePath( ) , 0 , &shFinfo , sizeof( shFinfo ) , SHGFI_SYSICONINDEX | SHGFI_OPENICON | SHGFI_DISPLAYNAME );
- s = shFinfo.iIcon;
- h = this->m_tree.InsertItem( find.GetFileName( ) , n , s , item );
- if( find.IsDirectory( ) )
- this->m_tree.InsertItem( "" , -1 , -1 , h );
- }
- }
- }
- void CDriverBar::OnItemexpandingTree( NMHDR* pNMHDR , LRESULT * pResult )
- {
- NM_TREEVIEW * pNMTreeView = ( NM_TREEVIEW * )pNMHDR;
- if( pNMTreeView->action == TVE_EXPAND )
- this->Expand( );
- *pResult = 0;
- }
- void CDriverBar::GetFullPath( CString & path , HTREEITEM hItem )
- {
- if( hItem == NULL )
- hItem = this->m_tree.GetSelectedItem( );
- CString text;
- while( hItem )
- {
- text = this->m_tree.GetItemText( hItem ) + "\" + text;
- hItem = this->m_tree.GetParentItem( hItem );
- }
- int i = text.Find( ':' , 0 );
- path.Format( "%c:\%s" , text[ i - 1 ] , text.Mid( i + 3 , text.GetLength( ) - i - 4 ) );
- }