int CXTPSyntaxEditColorComboBox::SetAutoColor(COLORREF crColor, LPCTSTR lpszAutoText/*=NULL*/)
{
	CString csAuto;
	if (lpszAutoText == NULL)
	{
		XTPResourceManager()->LoadString(
			&csAuto, XTP_IDS_CLR_AUTOMATIC);

		int nTipIndex = csAuto.Find(_T('\n'), 0);
		if (nTipIndex > 0)
			csAuto.ReleaseBuffer(nTipIndex);
	}
	else
	{
		csAuto = lpszAutoText;
	}

	if (crColor == COLORREF_NULL)
	{
		m_crAuto = COLORREF_NULL;

		int iIndex = FindStringExact(-1, csAuto);
		if (iIndex != CB_ERR)
		{
			return DeleteString(iIndex);
		}

		return CB_ERR;
	}

	if (m_crAuto == COLORREF_NULL)
	{
		int iIndex = InsertString(0, csAuto);
		if (iIndex != CB_ERR)
		{
			m_crAuto = crColor;
			SetItemData(iIndex, (DWORD)m_crAuto);
			RedrawWindow();
			return iIndex;
		}
	}
	else
	{
		int iIndex = FindStringExact(-1, csAuto);
		if (iIndex != CB_ERR)
		{
			m_crAuto = crColor;
			SetItemData(iIndex, (DWORD)m_crAuto);
			RedrawWindow();
			return iIndex;
		}
	}

	return CB_ERR;
}
int CXTPSyntaxEditColorComboBox::SetUserColor(COLORREF crColor, LPCTSTR lpszUserText/*=NULL*/)
{
	CString csCustom;
	if (lpszUserText == NULL)
	{
		XTPResourceManager()->LoadString(
			&csCustom, XTP_IDS_EDIT_CUSTOM);
	}
	else
	{
		csCustom = lpszUserText;
	}

	if (crColor == COLORREF_NULL)
	{
		m_crUser = COLORREF_NULL;

		int iIndex = FindStringExact(-1, csCustom);
		if (iIndex != CB_ERR)
		{
			return DeleteString(iIndex);
		}

		return CB_ERR;
	}

	if (m_crUser == COLORREF_NULL)
	{
		int iIndex = AddString(csCustom);
		if (iIndex != CB_ERR)
		{
			m_crUser = crColor;
			SetItemData(iIndex, (DWORD)m_crUser);
			RedrawWindow();
			return iIndex;
		}
	}
	else
	{
		int iIndex = FindStringExact(-1, csCustom);
		if (iIndex != CB_ERR)
		{
			m_crUser = crColor;
			SetItemData(iIndex, (DWORD)m_crUser);
			RedrawWindow();
			return iIndex;
		}
	}

	return CB_ERR;
}
Пример #3
0
/******************************************************************************
	함수명		: AddItem(CString strName, CString strCode)
	함수설명	: 콤보박스에 아이템을 추가한다
	인자설명	: [IN] strName	: 콤보박스에 보여질 텍스트
				  [IN] strCode	: 콤보박스 아이템이 가질 코드값
								  ("`"구분자로 여러개의 코드 입력가능)
	
	리턴값		: 에러발생시 CB_ERR 리턴, 성공시 아이템갯수 리턴 
	최종수정일	: 2003년 10월 14일
	참고사항	: 
 ******************************************************************************/
int CIDMSComboBox::AddItem(CString strName, CString strCode)
{
	if( strCode.IsEmpty() == TRUE )
		return CB_ERR;

	// IDMSCOMBOBOX_DELIM 구분자 붙여준다
	if( strCode.Right(1) != IDMSCOMBOBOX_DELIM )
		strCode += IDMSCOMBOBOX_DELIM;

	// 처음입력일 경우 코드 컬럼갯수 설정
	if( GetCount() == 0 )
		m_nCodeCount = GetColCnt(strCode);
	else
	{
		// 코드갯수 체크
		if( m_nCodeCount != GetColCnt(strCode) )
			return CB_ERR;
	}
	
	// 이미 추가된 아이템이 아닐경우만 추가
	if( FindStringExact(0, strName) == CB_ERR  )
	{
		CComboBox::AddString(strName);
		m_astrName.Add(strName);
		m_astrCode.Add(strCode);
	}

	return GetCount();
}
Пример #4
0
/******************************************************************************
	함수명		: InsertItem(long nIndex, CString strName, CString strCode)
	함수설명	: 콤보박스에 아이템을 원하는 위치에 삽입한다
	인자설명	: [IN] nIndex	: 삽입될 위치
				  [IN] strName	: 콤보박스에 보여질 텍스트
				  [IN] strCode	: 콤보박스 아이템이 가질 코드값
								  ("`"구분자로 여러개의 코드 입력가능)
	
	리턴값		: 에러발생시 CB_ERR 리턴, 성공시 아이템갯수 리턴 
	최종수정일	: 2003년 10월 14일
	참고사항	: 
 ******************************************************************************/
int CIDMSComboBox::InsertItem(long nIndex, CString strName, CString strCode)
{
	if( strCode.IsEmpty() )
		return CB_ERR;

	// IDMSCOMBOBOX_DELIM 구분자 붙여준다
	if( strCode.Right(1) != IDMSCOMBOBOX_DELIM )
		strCode += IDMSCOMBOBOX_DELIM;

	if( GetCount() == 0 )
		return AddItem(strName, strCode);

	// 삽입범위 체크
	if( nIndex<0 || nIndex>=GetCount() )
		return CB_ERR;

	// 코드갯수 체크
	if( m_nCodeCount != GetColCnt(strCode) )
		return CB_ERR;
	
	// 이미 추가된 아이템이 아닐경우만 추가
	if( FindStringExact(0, strName) == CB_ERR )
	{
		CComboBox::InsertString(nIndex, strName);
		m_astrName.InsertAt(nIndex, strName);
		m_astrCode.InsertAt(nIndex, strCode);
	}

	return GetCount();
}
Пример #5
0
// this version of AddString adds a string only if it doesn't already exist
// in the list, and in any case, makes sure that the string is the first
// in the list (ie most recent in history)
// also makes sure number of items in the list doesn't exceed the maximum allowed
int CHistoryCombo::AddString(LPCTSTR lpszString)
{
	CString sString(lpszString);

	// if it's not set up as a history combo then call base class
	if (m_sSection.IsEmpty() || m_sKeyPrefix.IsEmpty())
		return CComboBox::AddString(lpszString);

	int nRet = -1;

	// don't add if already there
	sString.TrimLeft();
	sString.TrimRight();

	if (sString.IsEmpty())
	{
		TRACE(_T("ERROR  string is empty\n"));
		return CB_ERR;
	}

	nRet = CComboBox::InsertString(0, sString);
	int nIndex = FindStringExact(0, sString);
	if (nIndex != -1 && nIndex != 0)
		DeleteString(nIndex);

	// if we've got too many items then delete the last one
	// truncate list to m_nMaxHistoryItems
	int nNumItems = GetCount();
	for (int n = m_nMaxHistoryItems; n < nNumItems; n++)
		DeleteString(m_nMaxHistoryItems);

	SetCurSel(nRet);
	return nRet;
}
Пример #6
0
//***************************************************************************************
BOOL CBCGFontComboBox::Setup (int nFontType, BYTE nCharSet, BYTE nPitchAndFamily)
{
	ASSERT_VALID (this);
	ASSERT (::IsWindow (m_hWnd));
	
	if (m_bToolBarMode)
	{
		ASSERT (FALSE);
		return FALSE;
	}

	CleanUp ();

	CBCGToolbarFontCombo combo (0, (UINT)-1, nFontType, nCharSet,
								CBS_DROPDOWN, 0, nPitchAndFamily);

	for (int i = 0; i < combo.GetCount (); i++)
	{
		CString strFont = combo.GetItem (i);

		CBCGFontDesc* pFontDescrSrc = (CBCGFontDesc*) (DWORD_PTR) combo.GetItemData (i);
		ASSERT_VALID (pFontDescrSrc);

		if (FindStringExact (-1, strFont) <= 0)
		{
			CBCGFontDesc* pFontDescr = new CBCGFontDesc (*pFontDescrSrc);
			int iIndex = AddString (strFont);
			SetItemData (iIndex, (DWORD_PTR) pFontDescr);
		}
	}

	return TRUE;
}
Пример #7
0
void CSizeComboBox::InsertSize(int nSize)
{
	ASSERT(nSize > 0);
	DWORD dwSize = (DWORD)nSize;
	TCHAR buf[10];
	TwipsToPointString(buf, nSize);
	if (FindStringExact(-1, buf) == CB_ERR)
	{
		int nIndex = -1;
		int nPos = 0;
		DWORD dw;
		while ((dw = GetItemData(nPos)) != CB_ERR)
		{
			if (dw > dwSize)
			{
				nIndex = nPos;
				break;
			}
			nPos++;
		}
		nIndex = InsertString(nIndex, buf);
		ASSERT(nIndex != CB_ERR);
		if (nIndex != CB_ERR)
			SetItemData(nIndex, dwSize);
	}
}
Пример #8
0
LONG CAdvComboBox::OnSelectString( WPARAM wItemStart, LPARAM lString )
{
	int nItem = (int)wItemStart;
	TCHAR* pStr = (TCHAR*)lString;
	int nIndex = FindStringExact( nItem, pStr );
	return SetCurSel( nIndex );
}
Пример #9
0
void CLocalComboBox::SetTheText(LPCTSTR lpszText,BOOL bMatchExact)
{
	int idx = (bMatchExact) ? FindStringExact(-1,lpszText) :
		FindString(-1, lpszText);
	SetCurSel( (idx==CB_ERR) ? -1 : idx);
	if (idx == CB_ERR)
		SetWindowText(lpszText);
}
Пример #10
0
void CDurationComboBox::SetVal(double Val)
{
	CString	s(DurationToString(Val));
	int	iItem = FindStringExact(0, s);
	if (iItem >= 0)
		SetCurSel(iItem);
	else
		SetWindowText(s);	// order matters
	m_Duration = Val;
}
Пример #11
0
int CHgzComboBox::AddStringWithoutDuplication(LPCTSTR lpszString) // 1、大小写不敏感;2、首尾空格有效。
{
	CString cstr = lpszString;

	if (!cstr.IsEmpty() && (FindStringExact(-1, cstr)) == CB_ERR)
	{
		CComboBox::AddString(cstr);
		return TRUE;
	}

	return FALSE;
}
Пример #12
0
int CSmartComboBox::AddString(LPCTSTR str)
{
	if( _tcslen(str) == 0 )
		return -1;

	int oldIndex = FindStringExact(-1, str);
	if( oldIndex >= 0 )
		DeleteString(oldIndex);

	if( GetCount() == m_nMaxStrings )
		DeleteString(m_nMaxStrings-1);

	return CComboBox::InsertString(0, str);
}
Пример #13
0
int	 CComboBoxExt::AddString(LPCTSTR lpszString)
{
	
	if (lpszString == NULL) return -1;
	if(bhistory!=TRUE)
		return CComboBox::AddString(lpszString);
	//szCadAdd.TrimLeft(_T(" "));
	//szCadAdd.TrimRight(_T(" "));
	int nret=CComboBox::InsertString(0,lpszString);
	int nFindCad=FindStringExact(0, lpszString);
	if (nFindCad != -1 && nFindCad != 0)
		DeleteString(nFindCad );
	SetCurSel(nret);	
	return nret;
}
Пример #14
0
int CHistoryCombo::AddString(const CString& str, INT_PTR pos /* = -1*/, BOOL isSel /* = TRUE */)
{
	if (str.IsEmpty())
		return -1;

	if (pos < 0)
		pos = GetCount();

	CString combostring = str;
	combostring.Replace('\r', ' ');
	combostring.Replace('\n', ' ');
	if (m_bTrim)
		combostring.Trim();
	if (combostring.IsEmpty())
		return -1;

	//search the Combo for another string like this
	//and do not insert if found
	int nIndex = m_bCaseSensitive ? FindStringExactCaseSensitive(-1, combostring) : FindStringExact(-1, combostring);
	if (nIndex != -1)
	{
		if (nIndex > pos)
		{
			DeleteItem(nIndex);
			m_arEntries.RemoveAt(nIndex);
		}
		else
		{
			if(isSel)
				SetCurSel(nIndex);
			return nIndex;
		}
	}

	//truncate list to m_nMaxHistoryItems
	int nNumItems = GetCount();
	for (int n = m_nMaxHistoryItems; n < nNumItems; n++)
	{
		DeleteItem(m_nMaxHistoryItems);
		m_arEntries.RemoveAt(m_nMaxHistoryItems);
	}

	int nRet = InsertEntry(combostring, pos);

	if (isSel)
		SetCurSel(nRet);
	return nRet;
}
Пример #15
0
// this version of AddString adds a string only if it doesn't already exist
// in the list, and in any case, makes sure that the string is the first
// in the list (ie most recent in history)
// also makes sure number of items in the list doesn't exceed the maximum allowed
int CHistoryCombo::AddString(LPCTSTR lpszString)
{
  // if it's not set up as a history combo then call base class
  if (m_sSection.IsEmpty() || m_sKeyPrefix.IsEmpty())
    return CComboBox::AddString(lpszString);

  int nRet = -1;
  // don't add it already there
  CString sString(lpszString);
  sString.TrimLeft(" ");
  sString.TrimRight(" ");
  nRet = CComboBox::InsertString(0, sString);
  int nIndex = FindStringExact(0, sString);
  if (nIndex != -1 && nIndex != 0)
    DeleteString(nIndex);
  SetCurSel(nRet);
  return nRet;
}
Пример #16
0
// loads the history from the specified profile area, and returns the 
// text selected
// the profile area is kept so that in doesn't need to specified again
// when saving the history
CString CHistoryCombo::LoadHistory(LPCTSTR lpszSection, LPCTSTR lpszKeyPrefix, 
				   BOOL bSaveRestoreLastCurrent/*=TRUE*/, 
				   LPCTSTR lpszKeyCurItem/*=NULL*/)
{
  if (lpszSection == NULL || lpszKeyPrefix == NULL || *lpszSection == '\0')
    return "";

  m_sSection = lpszSection;
  m_sKeyPrefix = lpszKeyPrefix;
  m_sKeyCurItem = lpszKeyCurItem == NULL ? "" : lpszKeyCurItem;
  m_bSaveRestoreLastCurrent = bSaveRestoreLastCurrent;
  CWinApp* pApp = AfxGetApp();

  int n = 0;
  CString sText;
  do
  {
    CString sKey;
    sKey.Format("%s%d", m_sKeyPrefix, n++);
    sText = pApp->GetProfileString(m_sSection, sKey);
    if (!sText.IsEmpty())
      CComboBox::AddString(sText);
  }while (!sText.IsEmpty());
  if (m_bSaveRestoreLastCurrent)
  {
    CString sKey;
    if (!m_sKeyCurItem.IsEmpty())
      sKey = m_sKeyCurItem;
    else if (m_sKeyPrefix.IsEmpty())
      sKey = "Last";
    else
      sKey = m_sKeyPrefix;
    sText = pApp->GetProfileString(m_sSection, sKey);
    if (!sText.IsEmpty())
    {
      int nIndex = FindStringExact(-1, sText);
      if (nIndex != -1)
	SetCurSel(nIndex);
      else if (GetStyle() & CBS_DROPDOWN)
	SetWindowText(sText);
    }
  }
  return sText;
}
BOOL COXHistoryCombo::AddNewItem(LPCTSTR pszItemText /* = NULL */)
{
	ASSERT_VALID(this);
	CString sNewItem(pszItemText);

	if (sNewItem.IsEmpty())
		// ... No text was specified, get the text from the edit control
		GetWindowText(sNewItem);

	if (sNewItem.IsEmpty())
		// ... Do not add empty string to the list
		return FALSE;

	// Check whether the item is already in the list or not
	BOOL bAlreadyInList = FALSE;
	int nOldPos = FindStringExact(-1, sNewItem);
	if (nOldPos != CB_ERR)
	{
		// ... Already in the list, remove the old item
		DeleteString(nOldPos);
		bAlreadyInList = TRUE;
	}

	// ... Insert the new string at the top of the list and select it
	InsertString(0, sNewItem);
	SetCurSel(0);

	// If the list contains more items than allowed, truncate the list
	// ... Cast to DWORD so that -1 becomes a very large number
	if ((DWORD)m_nMaxHistoryCount < (DWORD)GetCount())
	{
		for (int nItemIndex = GetCount() - 1; m_nMaxHistoryCount <= nItemIndex; nItemIndex--)
		{
			DeleteString(nItemIndex);
		}
	}
	// ... Select the entire string
	SetEditSel(0, -1);

	ASSERT_VALID(this);
	return !bAlreadyInList;
}
int COXMultiComboBox::SelectString(int nStartAfter, int nColIndex, LPCTSTR lpszString)
{
	if(nColIndex >= m_nColumnCount || nColIndex < 0)
		return CB_ERR;

	int nIndex = FindStringExact(nStartAfter,nColIndex,lpszString);
	if(nIndex != CB_ERR)
	{
		COXRowData* pRowData = GetRowData(nIndex);
		if (pRowData != NULL)
			nIndex = CComboBox::SelectString(nStartAfter,pRowData->GetColumnString(m_nMasterColumn));
		else
		{
			TRACE0("In COXMultiComboBox::SelectString : GetRowData() returned NULL.\n");
			nIndex = CB_ERR;
		}
	}

	return nIndex;
}
Пример #19
0
// This will add the history of data used
LRESULT CToolBarCombo::AddtoHistory(const _bstr_t& bstrURL){
  CRegKey keyAppID;
  if(std::basic_string<TCHAR>(bstrURL).find_first_not_of(_T(" "))!=std::string::npos)  {
    int h = GetCount();
    int pos = FindStringExact(-1,bstrURL);
    if(pos == CB_ERR){
      if(h<50){
        InsertString(0,bstrURL);
      }else{
        DeleteString(h-1);
        InsertString(0,bstrURL);
      }
    }else{
      DeleteString(pos);
      InsertString(0,bstrURL);
    }

    {
      CRegKey keyAppID;
      keyAppID.Attach(Get6BeeAppRegistryKey());
      keyAppID.RecurseDeleteKey(_T("History"));
    }

    {
      CRegKey keyAppID;
      keyAppID.Create(Get6BeeAppRegistryKey(),_T("History"));

      for(int i=0;i < GetCount();i++)
      {
        TCHAR cValue[1024]={};
        GetLBText(i, cValue);
        keyAppID.SetDWORDValue(cValue,1);
      }
    }

    SetCurSel(0);
  }

  return 0;
}
Пример #20
0
LONG CAdvComboBox::OnSelectedItem( WPARAM wParam, LPARAM /*lParam*/ )
{
	list<LIST_ITEM> itemlist;
	list<LIST_ITEM>::iterator itemiter;

	int nPos = (int)wParam;
	itemlist = m_pDropWnd->GetList();
	itemiter = itemlist.begin();
	advance( itemiter, nPos );
	m_strEdit = itemiter->strText;

	m_nCurSel = FindStringExact( 0, m_strEdit.c_str() );

	SetWindowText( m_strEdit.c_str() );
	if( (GetStyle() & CBS_DROPDOWN) && !(GetStyle() & CBS_SIMPLE) )	// == CBS_DROPDOWN
	{
		if( m_pEdit )
		{
			m_pEdit->SetWindowText( m_strEdit.c_str() );
			m_pEdit->SetFocus();
			m_pEdit->SetSel( 0, -1, TRUE );
		}
	}
	// Send message to parent(dialog)
	m_bSelItem = true;
	int nId = GetDlgCtrlID();
	m_pParent->SendMessage( WM_COMMAND, MAKEWPARAM(nId,CBN_SELENDOK), (LPARAM)m_hWnd );

	Invalidate();
	OnDestroyDropdownList(0,0);

	//
	// See to it that the drop button is redrawn
	InvalidateRect( m_rcDropButton );

	m_pParent->SendMessage( WM_COMMAND, MAKEWPARAM(nId,CBN_SELCHANGE), (LPARAM)m_hWnd );

	return TRUE;
}
void CListCtrlComboBox::ShowEdit(int nItem,int nSubItem) {
    if (nItem < 0 || nSubItem < 0) return;
    if (m_pParentList == NULL) return ;
    CListCtrl *pCtrl = m_pParentList;
    CRect rect;
    m_pParentList = pCtrl;
//	m_pParentList->GetSubItemRect(nItem,nIndex,LVIR_LABEL,rcCtrl);

    // 列可见
    CHeaderCtrl* pHeader = (CHeaderCtrl*)pCtrl->GetDlgItem(0);
    int nColumnCount = pHeader->GetItemCount();
    if( nSubItem >= nColumnCount || pCtrl->GetColumnWidth(nSubItem) < 5 )
        return ;

    // 列偏移
    int offset = 0;
    for( int i = 0; i < nSubItem; i++ )
        offset += pCtrl->GetColumnWidth( i );

    pCtrl->GetItemRect( nItem, &rect, LVIR_BOUNDS );
    rect.top -= 2;
    if (rect.top < 0) rect.top = 0;
    // 滚动列,便于操作
    CRect rcClient;
    CSize size;
    pCtrl->GetClientRect( &rcClient );
//	if( offset + rect.left < 0 || offset + rect.left > rcClient.right )
    if( offset + rect.left < 0 ) {
        size.cx = offset + rect.left;
        size.cy = 0;
        pCtrl->Scroll( size );
        rect.left -= size.cx;
    } else if(offset + rect.left > rcClient.right ) {
        size.cx = offset + rect.left;
        size.cy = 0;
        pCtrl->Scroll( size );
        rect.left -= size.cx;
    }
    // 获取列的对齐方式
    LV_COLUMN lvcol;
    lvcol.mask = LVCF_FMT;
    pCtrl->GetColumn( nSubItem, &lvcol );
    DWORD dwStyle;
    if((lvcol.fmt&LVCFMT_JUSTIFYMASK) == LVCFMT_LEFT)
        dwStyle = ES_LEFT;
    else if((lvcol.fmt&LVCFMT_JUSTIFYMASK) == LVCFMT_RIGHT)
        dwStyle = ES_RIGHT;
    else dwStyle = ES_CENTER;

    rect.left += offset + 1;
    if (nSubItem > 0)
        rect.right = rect.left + pCtrl->GetColumnWidth( nSubItem );
    else
        rect.right = rect.left + pCtrl->GetColumnWidth( nSubItem );

    if( rect.right > rcClient.right)
        rect.right = rcClient.right;

    rect.bottom = rect.top + 12 * rect.Height();

    CString strItem = pCtrl->GetItemText(nItem,nSubItem);
    pCtrl->ClientToScreen(rect);
    GetParent()->ScreenToClient(rect);
    MoveWindow(rect);
//	SetWindowPos(NULL, rect.left,rect.top,rect.Width(),rect.Height(), SWP_SHOWWINDOW);
//	pCtrl->ClientToScreen(rcClient);
//	GetParent()->ScreenToClient(rcClient);
//	pCtrl->SetWindowPos(this, rcClient.left,rcClient.top,rcClient.Width(),rcClient.Height(), SWP_SHOWWINDOW);
    ShowWindow(SW_SHOW);
    SetWindowText(strItem);
    ::SetFocus(GetSafeHwnd());
    SetItemHeight(-1,13);
//设置对应选项
    int nIndex =  FindStringExact(0, strItem);
    if (nIndex < 0) nIndex = 0;
    SetCurSel(nIndex);
    m_nCurrentItem = nItem;
    m_nCurrentSubItem = nSubItem;
}
Пример #22
0
int CHistoryCombo::AddString(CString str, INT_PTR pos)
{
    if (str.IsEmpty())
        return -1;

    //truncate list to m_nMaxHistoryItems
    int nNumItems = GetCount();
    for (int n = m_nMaxHistoryItems; n < nNumItems; n++)
    {
        DeleteItem(m_nMaxHistoryItems);
        m_arEntries.RemoveAt(m_nMaxHistoryItems);
    }

    COMBOBOXEXITEM cbei;
    SecureZeroMemory(&cbei, sizeof cbei);
    cbei.mask = CBEIF_TEXT;

    if (pos < 0)
        cbei.iItem = GetCount();
    else
        cbei.iItem = pos;
    if (m_bTrim)
        str.Trim(L" ");
    CString combostring = str;
    combostring.Replace('\r', ' ');
    combostring.Replace('\n', ' ');
    cbei.pszText = const_cast<LPTSTR>(combostring.GetString());

#ifdef HISTORYCOMBO_WITH_SYSIMAGELIST
    if (m_bURLHistory)
    {
        cbei.iImage = SYS_IMAGE_LIST().GetPathIconIndex(str);
        if ((cbei.iImage == NULL) || (cbei.iImage == SYS_IMAGE_LIST().GetDefaultIconIndex()))
        {
            if (str.Left(5) == L"http:")
                cbei.iImage = SYS_IMAGE_LIST().GetPathIconIndex(L".html");
            else if (str.Left(6) == L"https:")
                cbei.iImage = SYS_IMAGE_LIST().GetPathIconIndex(L".html");
            else if (str.Left(5) == L"file:")
                cbei.iImage = SYS_IMAGE_LIST().GetDirIconIndex();
            else if (str.Left(4) == L"svn:")
                cbei.iImage = SYS_IMAGE_LIST().GetDirIconIndex();
            else if (str.Left(8) == L"svn+ssh:")
                cbei.iImage = SYS_IMAGE_LIST().GetDirIconIndex();
        }
        cbei.iSelectedImage = cbei.iImage;
        cbei.mask |= CBEIF_IMAGE | CBEIF_SELECTEDIMAGE;
    }
    if (m_bPathHistory)
    {
        cbei.iImage = SYS_IMAGE_LIST().GetPathIconIndex(str);
        if (cbei.iImage == SYS_IMAGE_LIST().GetDefaultIconIndex())
        {
            cbei.iImage = SYS_IMAGE_LIST().GetDirIconIndex();
        }
        cbei.iSelectedImage = cbei.iImage;
        cbei.mask |= CBEIF_IMAGE | CBEIF_SELECTEDIMAGE;
    }
#endif
    int nRet = InsertItem(&cbei);
    if (nRet >= 0)
        m_arEntries.InsertAt(nRet, str);

    //search the Combo for another string like this
    //and delete it if one is found
    if (m_bTrim)
        str.Trim();
    int nIndex = FindStringExact(0, combostring);
    if (nIndex != -1 && nIndex != nRet)
    {
        DeleteItem(nIndex);
        m_arEntries.RemoveAt(nIndex);
    }

    SetCurSel(nRet);
    return nRet;
}
Пример #23
0
// loads the history from the specified profile area, and returns the 
// text selected
// the profile area is kept so that in doesn't need to specified again
// when saving the history
CString CHistoryCombo::LoadHistory(LPCTSTR lpszSection, 
								   LPCTSTR lpszKeyPrefix,    
								   BOOL bSaveRestoreLastCurrent/*=TRUE*/,    
								   LPCTSTR lpszKeyCurItem/*=NULL*/)
{
	if (lpszSection == NULL || lpszKeyPrefix == NULL || *lpszSection == _T('\0'))
		return _T("");

	TRACE(_T("lpszSection=%s  lpszKeyPrefix=%s\n"), lpszSection, lpszKeyPrefix);

	m_sSection = lpszSection;
	m_sKeyPrefix = lpszKeyPrefix;
	m_sKeyCurItem = lpszKeyCurItem == NULL ? _T("") : lpszKeyCurItem;
	m_bSaveRestoreLastCurrent = bSaveRestoreLastCurrent;
	CWinApp* pApp = AfxGetApp();
	ASSERT(pApp);

	int n = 0;
	CString sText;
	do
	{
		CString sKey;
		sKey.Format(KEY_PREFIX_FORMAT, m_sKeyPrefix, n++);
		sText = pApp->GetProfileString(m_sSection, sKey);
		if (m_bCheckAccess)							//+++hd
		{											//+++hd
			if (_taccess(sText, 00) != -1)			//+++hd
			{										//+++hd
				if (!sText.IsEmpty())				//+++hd
					CComboBox::AddString(sText);	//+++hd
			}										//+++hd
		}											//+++hd
		else										//+++hd
		{
			if (!sText.IsEmpty())
				CComboBox::AddString(sText);
		}

	} while (!sText.IsEmpty() && n < m_nMaxHistoryItems);

	if (m_bSaveRestoreLastCurrent)
	{
		CString sKey;
		if (!m_sKeyCurItem.IsEmpty())
			sKey = m_sKeyCurItem;
		else if (m_sKeyPrefix.IsEmpty())
			sKey = _T("Last");
		else
			sKey = m_sKeyPrefix;
		sText = pApp->GetProfileString(m_sSection, sKey);

		if (!sText.IsEmpty())
		{
			int nIndex = FindStringExact(-1, sText);
			if (nIndex != -1)
			SetCurSel(nIndex);
			else if (GetStyle() & CBS_DROPDOWN)
			SetWindowText(sText);
		}
	}

	return sText;
}
int CBCGPRecentFilesListBox::AddItem(const CString& strFilePath, UINT nCmd, BOOL bPin)
{
	if (strFilePath.IsEmpty())
	{
		return -1;
	}

	TCHAR path[_MAX_PATH];   
	TCHAR name[_MAX_PATH];   
	TCHAR drive[_MAX_DRIVE];   
	TCHAR dir[_MAX_DIR];
	TCHAR fname[_MAX_FNAME];   
	TCHAR ext[_MAX_EXT];

#if _MSC_VER < 1400
	_tsplitpath (strFilePath, drive, dir, fname, ext);
	_tmakepath (path, drive, dir, NULL, NULL);
	_tmakepath (name, NULL, NULL, fname, ext);
#else
	_tsplitpath_s (strFilePath, drive, _MAX_DRIVE, dir, _MAX_DIR, fname, _MAX_FNAME, ext, _MAX_EXT);
	_tmakepath_s (path, drive, dir, NULL, NULL);
	_tmakepath_s (name, NULL, NULL, fname, ext);
#endif
	CString strItem;

	if (m_bFoldersMode)
	{
		CString strPath = path;
		if (strPath.GetLength() > 0 && 
			(strPath[strPath.GetLength() - 1] == _T('\\') || strPath[strPath.GetLength() - 1] == _T('/')))
		{
			strPath = strPath.Left(strPath.GetLength() - 1);
		}

		int nIndex = max(strPath.ReverseFind(_T('\\')), strPath.ReverseFind(_T('/')));
		if (nIndex >= 0)
		{
			strItem = strPath.Right(strPath.GetLength() - nIndex - 1);
		}
	}
	else
	{
		strItem = name;
	}

	strItem += _T("\n");
	strItem += path;

	int nIndex = -1;

	if (FindStringExact(-1, strItem) < 0)
	{
		nIndex = AddString(strItem);
		SetItemData(nIndex, (DWORD_PTR)nCmd);

		if (bPin)
		{
			SetItemPinned(nIndex);
		}

		CString strFile = m_bFoldersMode ? path : strFilePath;

		SHFILEINFO sfi;
		if (::SHGetFileInfo (strFile, 0, &sfi, sizeof(SHFILEINFO),
			SHGFI_ICON | SHGFI_SHELLICONSIZE | SHGFI_LARGEICON))
		{
			m_arIcons.Add(sfi.hIcon);
		}
		else
		{
			m_arIcons.Add(NULL);
		}
	}

	return nIndex;
}
Пример #25
0
BOOL CTDLLanguageComboBox::HasYourLanguage() const
{
	return (FindStringExact(0, _T("YourLanguage")) != -1);
}
Пример #26
0
//-----------------------------------------------------------------------------
// Purpose: Automatically selects the first matching combo box item when the
//			edit control's text changes.
//-----------------------------------------------------------------------------
void CAutoSelComboBox::OnUpdateText(void)
{
	int nCurSel = GetCurSel();
	int nNewSel = nCurSel;

	DWORD dwEditSel = GetEditSel();
	int nEditStart = LOWORD(dwEditSel);
	int nEditEnd = HIWORD(dwEditSel);

	char szTypedText[MAX_PATH];
	GetWindowText(szTypedText, sizeof(szTypedText));

	//
	// Select the first match in the list if what they typed is different from
	// the current selection. This won't do anything if they are deleting characters
	// from the end of the text.
	//
	int nTypedLen = strlen(szTypedText);
	int nLastLen = strlen(m_szLastText);

	bool bSearched = false;
	int nIndex = CB_ERR;
	if (strnicmp(szTypedText, m_szLastText, nTypedLen))
	{
		nIndex = FindString(-1, szTypedText);
		bSearched = true;
	}
	else if (nTypedLen < nLastLen)
	{
		// They deleted characters, try to match the shorter string exactly.
		nIndex = FindStringExact(-1, szTypedText);
		bSearched = true;
	}

	if (bSearched)
	{
		if (nCurSel != nIndex)
		{
			SetCurSel(nIndex);
			nNewSel = nIndex;
		}

		if (nIndex != CB_ERR)
		{
			// Found a match.
			if ((nEditEnd == -1) || (nEditEnd == (int)strlen(szTypedText)))
			{
				SetEditSel(strlen(szTypedText), -1);
			}
			else
			{
				SetEditSel(nEditStart, nEditEnd);
			}
		}
		else
		{
			// No match found.
			SetWindowText(szTypedText);
			SetEditSel(nEditStart, nEditEnd);
		}
	}

	strcpy(m_szLastText, szTypedText);

	if (nNewSel != m_nLastSel)
	{
		GetParent()->SendMessage(WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), CBN_SELCHANGE), (LPARAM)m_hWnd);
		m_nLastSel = nNewSel;
	}
}
Пример #27
0
int CHistoryCombo::AddString(CString str, INT_PTR pos,BOOL isSel)
{
	if (str.IsEmpty())
		return -1;

	if (pos < 0)
		pos = GetCount();

	if (m_bTrim)
		str.Trim(_T(" "));
	CString combostring = str;
	combostring.Replace('\r', ' ');
	combostring.Replace('\n', ' ');
	if (m_bTrim)
		combostring.Trim();

	//search the Combo for another string like this
	//and do not insert if found
	int nIndex = m_bCaseSensitive ? FindStringExactCaseSensitive(-1, combostring) : FindStringExact(-1, combostring);
	if (nIndex != -1)
	{
		if (nIndex > pos)
		{
			DeleteItem(nIndex);
			m_arEntries.RemoveAt(nIndex);
		}
		else
		{
			if(isSel)
				SetCurSel(nIndex);
			return nIndex;
		}
	}

	//truncate list to m_nMaxHistoryItems
	int nNumItems = GetCount();
	for (int n = m_nMaxHistoryItems; n < nNumItems; n++)
	{
		DeleteItem(m_nMaxHistoryItems);
		m_arEntries.RemoveAt(m_nMaxHistoryItems);
	}

	COMBOBOXEXITEM cbei;
	SecureZeroMemory(&cbei, sizeof cbei);
	cbei.mask = CBEIF_TEXT;
	cbei.iItem = pos;

	cbei.pszText = const_cast<LPTSTR>(combostring.GetString());

#ifdef HISTORYCOMBO_WITH_SYSIMAGELIST
	if (m_bURLHistory)
	{
		cbei.iImage = SYS_IMAGE_LIST().GetFileIconIndex(str);
		if (cbei.iImage == 0 || cbei.iImage == SYS_IMAGE_LIST().GetDefaultIconIndex())
		{
			if (str.Left(5) == _T("http:"))
				cbei.iImage = SYS_IMAGE_LIST().GetFileIconIndex(_T(".html"));
			else if (str.Left(6) == _T("https:"))
				cbei.iImage = SYS_IMAGE_LIST().GetFileIconIndex(_T(".html"));
			else if (str.Left(5) == _T("file:"))
				cbei.iImage = SYS_IMAGE_LIST().GetDirIconIndex();
			else if (str.Left(4) == _T("git:"))
				cbei.iImage = m_nGitIconIndex;
			else if (str.Left(4) == _T("ssh:"))
				cbei.iImage = m_nGitIconIndex;
			else
				cbei.iImage = SYS_IMAGE_LIST().GetDirIconIndex();
		}
		cbei.iSelectedImage = cbei.iImage;
		cbei.mask |= CBEIF_IMAGE | CBEIF_SELECTEDIMAGE;
	}
	if (m_bPathHistory)
	{
		cbei.iImage = SYS_IMAGE_LIST().GetFileIconIndex(str);
		if (cbei.iImage == SYS_IMAGE_LIST().GetDefaultIconIndex())
		{
			cbei.iImage = SYS_IMAGE_LIST().GetDirIconIndex();
		}
		cbei.iSelectedImage = cbei.iImage;
		cbei.mask |= CBEIF_IMAGE | CBEIF_SELECTEDIMAGE;
	}
#endif

	int nRet = InsertItem(&cbei);
	if (nRet >= 0)
		m_arEntries.InsertAt(nRet, str);

	if(isSel)
		SetCurSel(nRet);
	return nRet;
}
Пример #28
0
int CAdvComboBox::GetCurSel()
{
	CString str;
	GetText( str );
	return FindStringExact( -1, str );
}