HistroyCombo.cpp
资源名称:FTP总集.rar [点击查看]
上传用户:tjfeida
上传日期:2013-03-10
资源大小:1917k
文件大小:5k
源码类别:
Ftp客户端
开发平台:
Visual C++
- // HistroyCombo.cpp : implementation file
- //
- /*********************************************
- **该文件是属于WolfFTP工程中的。如果有什么问题
- **请联系
- ** tablejiang@21cn.com
- **或者访问
- ** http://wolfftp.51.net
- **以得到最新的支持。
- *********************************************/
- #include "stdafx.h"
- #include "HistroyCombo.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CHistroyCombo
- CHistroyCombo::CHistroyCombo()
- {
- }
- CHistroyCombo::~CHistroyCombo()
- {
- m_ImageList.Detach();
- m_ImageList.m_hImageList = NULL ;
- }
- BEGIN_MESSAGE_MAP(CHistroyCombo, CComboBoxEx)
- //{{AFX_MSG_MAP(CHistroyCombo)
- ON_CONTROL_REFLECT(CBN_CLOSEUP, OnCloseup)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CHistroyCombo message handlers
- /****************************************************
- ** @Description
- ** Get system image list.
- **
- ** @Parameter
- **
- **
- ** @Return:
- ** @Author: JHM
- ** e-mail: tablejiang@21cn.com
- ** @Date: 2001 3 26
- ****************************************************/
- BOOL CHistroyCombo::GetSysImgList()
- {
- SHFILEINFO shFinfo;
- HIMAGELIST hImgList = NULL;
- if ( GetImageList( ) )
- m_ImageList.Detach();
- hImgList = (HIMAGELIST)SHGetFileInfo( "C:\",
- 0,
- &shFinfo,
- sizeof( shFinfo ),
- SHGFI_SYSICONINDEX |
- SHGFI_SMALLICON );
- if ( !hImgList )
- {
- return FALSE;
- }
- m_ImageList.m_hImageList = hImgList ;
- SetImageList( &m_ImageList ) ;
- return TRUE; // OK
- }
- /****************************************************
- ** @Description
- **
- **
- ** @Parameter
- **
- **
- ** @Return:
- ** @Author: JHM
- ** e-mail: tablejiang@21cn.com
- ** @Date: 2001 3 26
- ****************************************************/
- void CHistroyCombo::OnCloseup()
- {
- // TODO: Add your control notification handler code here
- }
- /****************************************************
- ** @Description
- ** add a history path to this combox
- **
- ** @Parameter
- **
- **
- ** @Return:
- ** @Author: JHM
- ** e-mail: tablejiang@21cn.com
- ** @Date: 2001 3 26
- ****************************************************/
- BOOL CHistroyCombo::AddString(LPCTSTR strPath)
- {
- COMBOBOXEXITEM cbi;
- CString DisplayString = strPath ;
- cbi.mask = CBEIF_TEXT;
- cbi.iItem = 0 ;
- cbi.pszText = (LPTSTR)(LPCTSTR)DisplayString ;
- cbi.cchTextMax = DisplayString.GetLength() ;
- //cbi.iImage = iIcon ;
- //cbi.iSelectedImage = iSelIcon ;
- //cbi.iOverlay = 0 ;
- InsertItem( &cbi ) ;
- return true ;
- }
- /****************************************************
- ** @Description
- ** select specify path .
- **
- ** @Parameter
- **
- **
- ** @Return:
- ** @Author: JHM
- ** e-mail: tablejiang@21cn.com
- ** @Date: 2001 3 26
- ****************************************************/
- BOOL CHistroyCombo::SetItemSelect(LPCTSTR strItem)
- {
- CString strFind = strItem ;
- COMBOBOXEXITEM cbi;
- int iCount = GetCount( ) ;
- int i ;
- char findBuffer[MAX_PATH] ;
- if( strFind.GetLength() != 1 && ( strFind.Right( 1 ) == '\' || strFind.Right( 1 ) == '/' ) )
- {
- strFind.SetAt( strFind.GetLength() - 1 , ' ' ) ;
- }
- //find the path string .
- for( i = 0 ; i < iCount ; i ++ )
- {
- cbi.mask = CBEIF_TEXT ;
- cbi.iItem = i ;
- cbi.pszText = findBuffer ;
- cbi.cchTextMax = MAX_PATH ;
- GetItem( &cbi ) ;
- if( strcmp( cbi.pszText , strFind ) == 0 )
- {
- SetCurSel( i ) ;
- return true ;
- }
- }
- return false ;
- }
- /****************************************************
- ** @Description
- ** get selected text .
- **
- ** @Parameter
- **
- **
- ** @Return:
- ** @Author: JHM
- ** e-mail: tablejiang@21cn.com
- ** @Date: 2001 3 26
- ****************************************************/
- BOOL CHistroyCombo::GetSelectText(char *szBuffer)
- {
- int iCurSel = GetCurSel( ) ;
- if( iCurSel == CB_ERR )
- return false ;
- int iRet = GetLBText( iCurSel , szBuffer ) ;
- if( iRet == CB_ERR )
- return false ;
- return true ;
- }
- /****************************************************
- ** @Description
- ** delete all item .
- **
- ** @Parameter
- **
- **
- ** @Return:
- ** @Author: JHM
- ** e-mail: tablejiang@21cn.com
- ** @Date: 2001 3 26
- ****************************************************/
- BOOL CHistroyCombo::DeleteAllItem()
- {
- int iCount = GetCount( ) ;
- if( iCount == CB_ERR )
- return false ;
- for( int i = 0 ; i < iCount ; i ++ )
- {
- DeleteString( 0 ) ;
- }
- return true ;
- }