Пример #1
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);
}
Пример #2
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);
		}
	}
}
Пример #3
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;
}
Пример #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;
}
void COXHistoryCombo::OnEnable(BOOL bEnable)
{
	CComboBox::OnEnable(bEnable);
	SetEditSel(0,0);
	ASSERT(m_pToolbar!=NULL);
	m_pToolbar->EnableWindow(bEnable);
}
BOOL CDurationComboBox::PreTranslateMessage(MSG* pMsg) 
{
	if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN) {
		OnKillfocus();
		SetEditSel(0, -1);	// select entire text
	}
	return CComboBox::PreTranslateMessage(pMsg);
}
Пример #7
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) );
}
Пример #8
0
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( );
	}
}
BOOL COXHistoryCombo::RestoreContents(LPCTSTR pszValueName, 
									  LPCTSTR pszCompany /* = NULL */, 
									  LPCTSTR pszApplication /* = NULL*/ , 
									  HKEY hKeyRoot /* = HKEY_CURRENT_USER */, 
									  BOOL bRestoreFirstItem /* = TRUE */)
{
	ASSERT_VALID(this);

	CString sValueName(pszValueName);
	CString sCompany(pszCompany);
	CString sApplication(pszApplication);
	CString sContents;

	if (sValueName.IsEmpty())
	{
		TRACE0("COXHistoryCombo::SaveContents : No value name provided, failing\n");
		return FALSE;
	}

	if (sCompany.IsEmpty())
		sCompany = AfxGetApp()->m_pszRegistryKey;
	if (sCompany.IsEmpty())
	{
		TRACE0("COXHistoryCombo::SaveContents : No valid company name is provided, failing\n");
		return FALSE;
	}

	if (sApplication.IsEmpty())
		sApplication = AfxGetApp()->m_pszProfileName;

	BOOL bSuccess = LoadContentsFromRegistry(hKeyRoot, sCompany, sApplication, sValueName, sContents);
	if (bSuccess)
	{
		// ... Set the contents in the list box
		SetContents(sContents);

		// Select the first item from the list
		if (bRestoreFirstItem)
		{
			SetCurSel(0);

			if (::IsWindow(GetSafeHwnd())
				&& GetFocus()==this && ::IsWindowEnabled(m_hWnd))
			SetEditSel(0, -1);
		}
	}

	ASSERT_VALID(this);
	return bSuccess;
}
Пример #10
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;
}
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;
}
Пример #12
0
BOOL CConsoleCombo::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class

	if (pMsg->message == WM_KEYDOWN)
	{
		CString str;				
		int nVirtKey = (int) pMsg->wParam;

		
		switch (nVirtKey)
		{
		//checks if up arrow key is pressed
		case VK_UP:
			
			//if this is first position save current text
			if (m_nPos == -1)
			{
				GetWindowText(str);
				m_current = str;
			}

			
			//makes sure an invalid position isn't going to be set
			if (m_nPos + 1 < GetCount())
			{				
				//increase position
				m_nPos++;
				//get text at current position display it highlighted
				GetLBText(m_nPos, str);
				SetWindowText(str);
				SetEditSel(0, str.GetLength());									
				
			}

			
			return TRUE;
		
		case VK_DOWN:
			
			//if going back to bottem restore previously entered text
			if (m_nPos - 1 == -1)
			{
				SetWindowText(m_current);
				SetEditSel(m_current.GetLength(), m_current.GetLength());
				m_nPos = -1;
			}
			
			if (m_nPos - 1 >= 0)
			{
								
				//decrease position
				m_nPos--;
				//get text at current position display it highlighted
				GetLBText(m_nPos, str);
				SetWindowText(str);
				SetEditSel(0, str.GetLength());								
				
			}
			return TRUE;
		
		//if enter key is pressed do following
		case VK_RETURN:
			
			GetWindowText(str);
			
			//make sure there is something input
			if (str != _T(""))
			{			
				//add string to the bottem of the list
				InsertString(0, str);
				m_nPos = -1;
				SetWindowText(_T(""));

				//function that must be customized for each program				
				ParseCommand(str);

			}
			break;
		
		}

		
		
	}
	
	return CComboBox::PreTranslateMessage(pMsg);
}
Пример #13
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;
	}
}