示例#1
0
void CGuiComboFont::OnCbnEditupdate()
{
	CString m_szCad;
	GetWindowText(m_szCad);
	
	DWORD m_dwCurRange = GetEditSel();
	DWORD m_dwStart    = LOWORD(m_dwCurRange);
	DWORD m_dwEnd      = HIWORD(m_dwCurRange);
	// se busca la cadena aprox, si no existe se debe insertar
	
	if (SelectString(-1, m_szCad) == CB_ERR)
	{
		SetCurSel(0);
	}
	else
	{
		if (m_dwCurRange != CB_ERR)
		{
			if (m_dwEnd <(DWORD) m_szCad.GetLength())
				SetEditSel(m_dwStart, m_dwEnd);
			else
				SetEditSel(m_szCad.GetLength(), - 1);
		}
	}
}
示例#2
0
LRESULT CToolBarCombo::OnEditChange(WORD wNotifyCode,WORD wID,HWND hWndCtl,BOOL& bHandled){
  // Get the text in the edit box
  wchar_t str[1024]={};
  GetWindowText(str, 1024);
  int nLength = GetWindowTextLength();

  updateBoxLen(str);

  if (!m_bAuto){
    return 0;
  }
  // Currently selected range
  DWORD dwCurSel = GetEditSel();
  WORD dStart = LOWORD(dwCurSel), dEnd = HIWORD(dwCurSel);

  // Search for, and select in, and string in the combo box that is prefixed by the text in the edit box
  //if (SelectString(-1, _bstr_t(str)) == CB_ERR){
  if (SelectString(-1, str) == CB_ERR){
    SetWindowText(str);    // No text selected, so restore what was there before
    if (dwCurSel != CB_ERR)
      SetEditSel(dStart, dEnd);  // restore cursor postion
  }
  // Set the text selection as the additional text that we have added
  if (dEnd < nLength && dwCurSel != CB_ERR)
    SetEditSel(dStart, dEnd);
  else
    SetEditSel(nLength, -1);
  return 0;
}
示例#3
0
void CCJFlatComboBox::OnEditUpdate() 
{
	// if we are not to auto update the text, get outta here
	if (!m_bAutoComp) 
		return;
	
	// Get the text in the edit box
	CString str;
	GetWindowText(str);
	int nLength = str.GetLength();
	
	// Currently selected range
	DWORD dwCurSel = GetEditSel();
	WORD dStart = LOWORD(dwCurSel);
	WORD dEnd   = HIWORD(dwCurSel);
	
	// Search for, and select in, and string in the combo box that is prefixed
	// by the text in the edit box
	if (SelectString(-1, str) == CB_ERR)
	{
		SetWindowText(str);		// No text selected, so restore what was there before
		if (dwCurSel != CB_ERR)
			SetEditSel(dStart, dEnd);	//restore cursor postion
	}
	
	// Set the text selection as the additional text that we have added
	if (dEnd < nLength && dwCurSel != CB_ERR)
		SetEditSel(dStart, dEnd);
	else
		SetEditSel(nLength, -1);
}
示例#4
0
void CComboBoxExt::OnCbnEditUpdate()
{
  LPTSTR m_szCad;
  m_szCad= (LPTSTR) new BYTE[(100)*sizeof(TCHAR)];
  memset(m_szCad,0x00,100);
  GetWindowText(m_szCad,100);
  
  DWORD m_dwCurRange=GetEditSel();
  DWORD m_dwStart=LOWORD(m_dwCurRange);
  DWORD m_dwEnd = HIWORD(m_dwCurRange);
  //se busca la cadena aprox, si no existe se debe insertar
 
	if (SelectString(-1,m_szCad) == CB_ERR)
	{
		SetWindowText(m_szCad);
		SetEditSel(m_dwStart,m_dwEnd);
	}
	else
	{
		if (m_dwCurRange != (DWORD)CB_ERR)
		{
			if (m_dwEnd <(DWORD) strlen(m_szCad))
				SetEditSel(m_dwStart,m_dwEnd);
			else
				SetEditSel(strlen(m_szCad),-1);
		}
	}

	
	delete [] (BYTE*)m_szCad;
}
示例#5
0
BOOL CInPlaceList::OnEditchange()
{
    // TODO: Add your control notification handler code here

    m_bEdit = TRUE;
    DWORD dwGetSel = GetEditSel();
    WORD wStart = LOWORD(dwGetSel);
    WORD wEnd	= HIWORD(dwGetSel);
    GetWindowText(m_sTypedText);
    CString sEditText(m_sTypedText);
    sEditText.MakeLower();

    CString sTemp, sFirstOccurrence;
    const BOOL bEmpty = m_sTypedText.IsEmpty();
    POSITION pos = m_PtrList.GetHeadPosition();
    while(! bEmpty && pos)
    {
        CItemData* pData = m_PtrList.GetNext(pos);
        sTemp = pData->m_sItem;
        sTemp.MakeLower();
        if (StringIsLike(sEditText + "*", sTemp))
            AddItem(pData);
        else
            DeleteItem(pData);
    }

    if(GetCount() < 1 || bEmpty)
    {
        if(GetDroppedState())
            ShowDropDown(FALSE);
        else
        {
            pos = m_PtrList.GetHeadPosition();
            while(pos)
                AddItem(m_PtrList.GetNext(pos));
        }
    }
    else
    {
        ShowDropDown();
        FitDropDownToItems();
    }

    UpdateText(m_sTypedText);
    SetEditSel(wStart,wEnd);

    m_bEdit = FALSE;

    return Default() != 0;
}
void CSearchBox::OnEditchange() 
{
	// TODO: Add your control notification handler code here
	DWORD dwEditSel = GetEditSel();

	CString	strText;
	GetWindowText( strText );
	
	int nFind	=	FindString( 0, strText );
	SetCurSel( nFind );
	if( !GetDroppedState() )
		ShowDropDown( );
	SetWindowText( strText );

	SetEditSel( 0, -1 );
	SetEditSel( LOWORD(dwEditSel), HIWORD(dwEditSel) );
}
void CSearchBox::OnChangeStatus( int nVirtKey, long lParam, BOOL bFocused )
{
	CString	strText;
	GetWindowText( strText );
	int	nCurSel	=	GetCurSel();

	/* VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) */
	/* VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) */

	if( IsWantChar( nVirtKey ) && !IsCTRLpressed() )	//	Ctrl Key Not Pressed
	{
		if( !bFocused )
			m_hwndLastFocus	=	::SetFocus( m_hWnd );

		if( m_bSegmentEnd )
		{
			strText	=	VirtKeyToChar( nVirtKey );
			m_bSegmentEnd	=	FALSE;
			
			SetWindowText( strText );
			SetEditSel( strText.GetLength(), strText.GetLength() );
		}
		else
		{
			DWORD dwEditSel = GetEditSel();
			if( CB_ERR != dwEditSel && LOWORD(dwEditSel) <= strText.GetLength() && HIWORD(dwEditSel) <= strText.GetLength() )
			{
				CString	strTemp	=	strText.Left( LOWORD(dwEditSel) );
				strTemp	+=	VirtKeyToChar( nVirtKey );
				strTemp	+=	strText.Mid( HIWORD(dwEditSel) );
				strText	=	strTemp;
				SetWindowText( strText );
				SetEditSel( LOWORD(dwEditSel)+1, LOWORD(dwEditSel)+1 );
			}
			else
			{
				strText	+=	VirtKeyToChar( nVirtKey );
				SetWindowText( strText );
				SetEditSel( strText.GetLength(), strText.GetLength() );
			}
		}
		
		OnEditchange( );
	}
}
//-----------------------------------------------------------------------------
// 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;
	}
}