JobListCtrl.cpp
资源名称:FTP总集.rar [点击查看]
上传用户:tjfeida
上传日期:2013-03-10
资源大小:1917k
文件大小:6k
源码类别:
Ftp客户端
开发平台:
Visual C++
- // JobListCtrl.cpp : implementation file
- //
- /*********************************************
- **该文件是属于WolfFTP工程中的。如果有什么问题
- **请联系
- ** tablejiang@21cn.com
- **或者访问
- ** http://wolfftp.51.net
- **以得到最新的支持。
- *********************************************/
- #include "stdafx.h"
- #include "QuickFTP.h"
- #include "JobListCtrl.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CJobListCtrl
- CJobListCtrl::CJobListCtrl()
- {
- }
- CJobListCtrl::~CJobListCtrl()
- {
- }
- BEGIN_MESSAGE_MAP(CJobListCtrl, CListCtrl)
- //{{AFX_MSG_MAP(CJobListCtrl)
- ON_WM_CREATE()
- ON_WM_KEYDOWN()
- ON_WM_RBUTTONUP()
- ON_WM_RBUTTONDOWN()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CJobListCtrl message handlers
- /****************************************************
- ** @Description
- **
- **
- ** @Parameter
- **
- **
- ** @Return:
- ** @Author: JHM
- ** e-mail: tablejiang@21cn.com
- ** @Date: 2001 3 26
- ****************************************************/
- BOOL CJobListCtrl::AddItem( FTPFILEINFO* pFile , int iItem )
- {
- char szTemp[MAX_PATH] ;
- InsertItem( iItem , pFile->remotefilename , pFile->state );
- _i64toa( pFile->filesize , szTemp , 10 ) ;
- SetItemText( iItem , 1 , szTemp ) ;
- //is directory
- if( pFile->bIsDirectory )
- SetItemText( iItem , 2 , "文件夹" ) ;
- else
- SetItemText( iItem , 2 , "文件" ) ;
- //transmit type .
- if( !pFile->bfileput )
- SetItemText( iItem , 3 , "下载" ) ;
- else
- SetItemText( iItem , 3 , "上传" ) ;
- SetItemText( iItem , 4 , pFile->site.host ) ;
- SetItemText( iItem , 5 , pFile->remotepath ) ;
- SetItemText( iItem , 6 , pFile->localpath ) ;
- SetItemText( iItem , 7 , pFile->site.user ) ;
- return true ;
- }
- /****************************************************
- ** @Description
- **
- **
- ** @Parameter
- **
- **
- ** @Return:
- ** @Author: JHM
- ** e-mail: tablejiang@21cn.com
- ** @Date: 2001 3 26
- ****************************************************/
- BOOL CJobListCtrl::GetItemInfo(int iItem, FTPFILEINFO *pFile)
- {
- char szTemp[MAX_PATH] ;
- LVITEM lv ;
- lv.mask = LVIF_IMAGE | LVIF_TEXT ;
- lv.iItem = iItem ;
- lv.iSubItem = 0 ;
- lv.pszText = szTemp ;
- lv.cchTextMax = MAX_PATH ;
- if( GetItem( &lv ) )
- {
- pFile->state = lv.iImage ;
- strcpy( pFile->remotefilename , lv.pszText ) ;
- }
- else
- {
- pFile->state = 1 ;
- strcpy( pFile->remotefilename , GetItemText( iItem , 0 ) ) ;
- }
- strcpy( szTemp , GetItemText( iItem , 1 ) ) ;
- pFile->filesize = _atoi64( szTemp ) ;
- strcpy( pFile->site.host , GetItemText( iItem , 4 ) ) ;
- strcpy( pFile->remotepath , GetItemText( iItem , 5 ) ) ;
- strcpy( pFile->localpath , GetItemText( iItem , 6 ) ) ;
- strcpy( pFile->site.user , GetItemText( iItem , 7 ) ) ;
- return true ;
- }
- int CJobListCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CListCtrl::OnCreate(lpCreateStruct) == -1)
- return -1;
- // TODO: Add your specialized creation code here
- InsertColumn( 0 , "文件" , LVCFMT_LEFT , 50 ) ;
- InsertColumn( 1 , "大小" , LVCFMT_LEFT , 50 ) ;
- InsertColumn( 2 , "文件类型" , LVCFMT_LEFT , 80 ) ;
- InsertColumn( 3 , "传输类型" , LVCFMT_LEFT , 80 ) ;
- InsertColumn( 4 , "服务器" , LVCFMT_LEFT , 60 ) ;
- InsertColumn( 5 , "远程路经" , LVCFMT_LEFT , 80 ) ;
- InsertColumn( 6 , "本地路径" , LVCFMT_LEFT , 80 ) ;
- InsertColumn( 7 , "用户" , LVCFMT_LEFT , 50 ) ;
- InitImageList( ) ;
- return 0;
- }
- /****************************************************
- ** @Description
- **
- **
- ** @Parameter
- **
- **
- ** @Return:
- ** @Author: JHM
- ** e-mail: tablejiang@21cn.com
- ** @Date: 2001 3 26
- ****************************************************/
- BOOL CJobListCtrl::InitImageList()
- {
- m_ImageList.Create( 16 , 16 , ILC_COLOR8, 0, 4);
- m_ImageList.Add( AfxGetApp()->LoadIcon( IDI_ICON_READY ) ) ;
- m_ImageList.Add( AfxGetApp()->LoadIcon( IDI_ICON_ERROR ) ) ;
- m_ImageList.Add( AfxGetApp()->LoadIcon( IDI_ICON_STOP ) ) ;
- m_ImageList.Add( AfxGetApp()->LoadIcon( IDI_ICON_RUNNING ) ) ;
- m_ImageList.Add( AfxGetApp()->LoadIcon( IDI_ICON_PAUSE ) ) ;
- SetImageList( &m_ImageList , LVSIL_SMALL ) ;
- return true ;
- }
- void CJobListCtrl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
- {
- // TODO: Add your message handler code here and/or call default
- switch( nChar )
- {
- case VK_DELETE :
- ::PostMessage( m_hParentWnd , JOBLIST_KEYDOWN_MSG , VK_DELETE , 0 ) ;
- break ;
- default :
- break ;
- }
- CListCtrl::OnKeyDown(nChar, nRepCnt, nFlags);
- }
- /****************************************************
- ** @Description
- **
- **
- ** @Parameter
- **
- **
- ** @Return:
- ** @Author: JHM
- ** e-mail: tablejiang@21cn.com
- ** @Date: 2001 3 26
- ****************************************************/
- void CJobListCtrl::SetParentWnd(HWND hWnd)
- {
- m_hParentWnd = hWnd ;
- }
- /****************************************************
- ** @Description
- **
- **
- ** @Parameter
- **
- **
- ** @Return:
- ** @Author: JHM
- ** e-mail: tablejiang@21cn.com
- ** @Date: 2001 3 26
- ****************************************************/
- BOOL CJobListCtrl::SetRowFullSelect()
- {
- SetExtendedStyle( LVS_EX_FULLROWSELECT /*| LVS_EX_GRIDLINES*/ );
- return true ;
- }
- void CJobListCtrl::OnRButtonUp(UINT nFlags, CPoint point)
- {
- // TODO: Add your message handler code here and/or call default
- CListCtrl::OnRButtonUp(nFlags, point);
- //::PostMessage( m_hParentWnd , JOBLIST_RBTN_UP_MSG , 0 , 0 ) ;
- }
- void CJobListCtrl::OnRButtonDown(UINT nFlags, CPoint point)
- {
- // TODO: Add your message handler code here and/or call default
- ::PostMessage( m_hParentWnd , JOBLIST_RBTN_UP_MSG , 0 , 0 ) ;
- CListCtrl::OnRButtonDown(nFlags, point);
- }
- /****************************************************
- ** @Description
- **
- **
- ** @Parameter
- **
- **
- ** @Return:
- ** @Author: JHM
- ** e-mail: tablejiang@21cn.com
- ** @Date: 2001 3 26
- ****************************************************/
- BOOL CJobListCtrl::SelectAllItem()
- {
- int iCount = GetItemCount( ) ;
- if( iCount == 0 )
- return true ;
- for( int i = 0 ; i < iCount ; i ++ )
- {
- SetItemState( i , LVIS_SELECTED , LVIS_SELECTED ) ;
- }
- //Invalidate( ) ;
- return true ;
- }