void CDateComboBox::SetCurrentWindowText( )
{
	if( !::IsWindow(m_hWnd) )
		return;

	DWORD	dwDate = -1;
	AfxGetSListStockContainer().GetCurrentType(NULL,NULL,&dwDate);
	CSPTime	sptime;
	if( DWORD(-2) == dwDate )
	{
		CString	strItem;
		strItem.LoadString( IDS_DATECOMBOBOX_MORE );
		SelectString( 0, strItem );
	}
	else if( DWORD(-1) == dwDate )
	{
		CString	strItem;
		strItem.LoadString( IDS_DATECOMBOBOX_NOW );
		SelectString( 0, strItem );
	}
	else if( sptime.FromStockTimeDay( dwDate ) )
	{
		CString	strItem	=	AfxGetTimeString( sptime.GetTime(), szDateComboBoxTimeFormat, TRUE );
		SelectString( 0, strItem );
	}
	else
	{
		CString	strItem;
		strItem.LoadString( IDS_DATECOMBOBOX_NOW );
		SelectString( 0, strItem );
	}
}
BOOL CSearchBox::InitStocks( BOOL bHasSTTTech, BOOL bShowOnSel, BOOL bDuplicate )
{
	ResetContent( );

	m_bShowOnSel	=	bShowOnSel;

	CStockContainer & container	=	AfxGetStockContainer();
	InitStorage( bDuplicate ? container.GetSize()*2 : container.GetSize(), 32 );
	for( int i=0; i<container.GetSize(); i++ )
	{
		CStockInfo	& info	=	container.ElementAt(i);
		if( !info.IsValidStock() )
			continue;

		CString	strTemp	=	info.GetStockCode();
		while( strTemp.GetLength() < 8 )
			strTemp	+=	' ';
		strTemp	+=	info.GetStockName();
		int	nItem	=	AddString( strTemp );
		SetItemData( nItem, i );

		if( bDuplicate )
		{
			strTemp	=	info.GetStockShortName();
			while( strTemp.GetLength() < 8 )
				strTemp	+=	' ';
			strTemp	+=	info.GetStockName();
			if( CB_ERR == SelectString( 0, strTemp ) )
			{
				nItem = AddString( strTemp );
				SetItemData( nItem, i );
			}
		}
	}
	if( bHasSTTTech )
	{
		// 技术指标项
		UINT nTechUserCount = CTechUser::GetTechUserCount();
		for( UINT i=STT_MIN; i <= STT_MAX+nTechUserCount; i ++ )
		{
			UINT	nTech	=	i;
			if( nTech > STT_MAX )
				nTech	=	i-STT_MAX-1+STT_USER_MIN;
		
			CString	strTemp	=	AfxGetSTTShortName( nTech );
			while( strTemp.GetLength() < 8 )
				strTemp	+=	' ';
			strTemp	+=	AfxGetSTTName( nTech );
			int	nItem	=	AddString( strTemp );
			SetItemData( nItem, nTech | SEARCHBOX_SIGNBIT_STT );
		}
		// 快捷键项
		for( UINT i = ACCE_MIN; i <= ACCE_MAX; i++ )
		{
			CString	strTemp	=	AfxGetAccelerator( i, 8 );
			SetItemData( AddString(strTemp), i | SEARCHBOX_SIGNBIT_ACCE );
		}
	}
	return TRUE;
}
BOOL COXMultiComboBox::SetMasterColumn(int nCol)
{
	if(nCol == m_nMasterColumn)
		return TRUE;

	// Master Column index should be in between 0 and m_nColumnCount-1
	if ((m_nColumnCount <= nCol) || (nCol < 0))
		return FALSE;

	int nPrevMasterColumn = m_nMasterColumn;
	CString sPrevMasterColumnString;
	int nCurSel = GetCurSel();
	if(nCurSel!=-1)
		GetLBText(GetCurSel(),sPrevMasterColumnString);

	m_nMasterColumn = nCol;

	// Resorts based on newly set master column
	if(!ChangeMasterColumn(nCol))
	{
		m_nMasterColumn = nPrevMasterColumn;
		return FALSE;
	}

	// Selects the string in newly set master column into editbox of combo 
	if(nCurSel!=-1)
		if((SelectString(-1,nPrevMasterColumn,sPrevMasterColumnString.GetBuffer(0)))==CB_ERR)
			return FALSE;
	return TRUE;
}
示例#4
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);
		}
	}
}
示例#5
0
int CPopupCombo::DoModal()
{
	static const int	DROPDOWN_HEIGHT = 100;
	int	retc = IDABORT;
	m_MouseHook = SetWindowsHookEx(WH_MOUSE, MouseProc, 
		AfxGetApp()->m_hInstance, AfxGetApp()->m_nThreadID);
	if (m_MouseHook != NULL) {
		CString	Text;
		OnBeginEdit(Text);
		CRect	r;
		if (m_Rect != NULL)	// if ctor was passed a rect, use it
			r = *m_Rect;
		else	// otherwise use parent's client rect
			m_Parent->GetClientRect(r);
		// create the edit control
		r.OffsetRect(1, -2);	// fudge to line up with grid control
		r.bottom += DROPDOWN_HEIGHT;	// expand to include drop list
		if (Create(m_Style, r, m_Parent, 0)) {
			PostMessage(CB_SHOWDROPDOWN, TRUE);	// show drop list
			// set font to parent's font
			SetFont(m_Parent->GetFont());
			for (int i = 0; i < m_ComboStr.GetSize(); i++)
				AddString(m_ComboStr[i]);
			m_OrigSel = SelectString(-1, Text);
			SetFocus();
			retc = RunModalLoop();
			DestroyWindow();
		}
		UnhookWindowsHookEx(m_MouseHook);
		m_MouseHook = NULL;
	}
    return(retc);
}
示例#6
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;
}
示例#7
0
/*----------------------------------------------------------------------
  TtaSelectString

  Selects a substring within a Text basic element. This substring is
  highlighted in all views where it can be displayed.

  Parameters:
  document: the document containing the string to be selected.
  textElement: the Text element containing the string to be selected.
  firstCharacter: position within the text element of the first character
  to be selected.
  lastCharacter: position within the text element of the last character
  to be selected.

  ----------------------------------------------------------------------*/
void  TtaSelectString (Document document, Element textElement,
                       int firstCharacter, int lastCharacter)
{
  DisplayMode         dispMode;

  UserErrorCode = 0;
  if (textElement == NULL)
    TtaError (ERR_invalid_parameter);
  else if (((PtrElement) textElement)->ElParent == NULL)
    TtaError (ERR_invalid_parameter);
  else if (!((PtrElement) textElement)->ElTerminal)
    TtaError (ERR_invalid_element_type);
  else if (((PtrElement) textElement)->ElLeafType != LtText &&
           ((PtrElement) textElement)->ElLeafType != LtSymbol &&
           ((PtrElement) textElement)->ElLeafType != LtPicture)
    TtaError (ERR_invalid_element_type);
  /* Checks the parameter document */
  else if (document < 1 || document > MAX_DOCUMENTS)
    TtaError (ERR_invalid_document_parameter);
  else if (LoadedDocument[document - 1] == NULL)
    TtaError (ERR_invalid_document_parameter);
  else
    {
      dispMode = TtaGetDisplayMode (document);
      if (dispMode == DisplayImmediately)
        {
          SelectString (LoadedDocument[document - 1],
                        (PtrElement) textElement, firstCharacter, lastCharacter);
        }
      else
        NewSelection (document, textElement, NULL, firstCharacter, lastCharacter);
    }
}
示例#8
0
BOOL CTimeComboBox::Set24HourTime(double dTime)
{
	if (dTime < 0)
	{
		SetCurSel(0);
		return TRUE;
	}
	
	// else
	if (dTime >= 24.0)
		return FALSE;

	// add on half a minute to handle floating point inaccuracies
	dTime += (0.5 / (24 * 60));

	int nHour = (int)dTime;
	int nMin = (int)((dTime - nHour) * 60); // nearest 1 minute

	CString sTime;
  
  if (m_dwStyle & TCB_ISO)
    sTime = CTimeHelper::FormatISOTime(nHour, nMin);
  else
    sTime = CTimeHelper::Format24HourTime(nHour, nMin);

	if (SelectString(-1, sTime) == CB_ERR)
		SetWindowText(sTime);

	return TRUE;
}
示例#9
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);
}
示例#10
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;
}
示例#11
0
void CSearchBox::SetCurrentWindowText( )
{
	if( !::IsWindow(m_hWnd) )
		return;

	if( !m_bShowOnSel )
		return;

	CStockInfo	info;
	if( AfxGetProfile().GetCurrentStock( &info ) )
	{
		if( CB_ERR == SelectString( 0, info.GetStockCode() ) )
			SetWindowText( info.GetStockCode() );
	}
	else
	{
		SetWindowText( NULL );
	}
}
示例#12
0
void CSearchBox::OnSelendcancel()
{
	// TODO: Add your control notification handler code here
	if( m_bDoNothing )
		return;

	m_bDoNothing	=	TRUE;
	if( m_hwndLastFocus )
		::SetFocus( m_hwndLastFocus );
	m_hwndLastFocus	=	NULL;
	m_bSegmentEnd	=	TRUE;

	CString	strCommand;
	GetWindowText( strCommand );
	int nSel = SelectString( 0, strCommand );
	ShowDropDown( FALSE );
	SetCurSel( nSel );

	SetCurrentWindowText( );
	m_bDoNothing	=	FALSE;

	if( m_bAutoHide )
		SetWindowPos( NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_HIDEWINDOW );
}
示例#13
0
CInPlaceList::CInPlaceList(CWnd* pParent, CRect& rect, DWORD dwStyle, UINT nID,
                           int nRow, int nColumn,
						   CStringArray& Items, CString sInitText,
						   UINT nFirstChar)
{
	m_nNumLines = 4;
	m_sInitText = sInitText;
 	m_nRow		= nRow;
 	m_nCol      = nColumn;
 	m_nLastChar = 0;
	m_bExitOnArrows = FALSE; //(nFirstChar != VK_LBUTTON);	// If mouse click brought us here,

	// Create the combobox
 	DWORD dwComboStyle = WS_BORDER|WS_CHILD|WS_VISIBLE|WS_VSCROLL|
 					     CBS_AUTOHSCROLL | dwStyle;
	int nHeight = rect.Height();
	rect.bottom = rect.bottom + m_nNumLines*nHeight + ::GetSystemMetrics(SM_CYHSCROLL);
	if (!Create(dwComboStyle, rect, pParent, nID)) return;

	// Add the strings
	for (int i = 0; i < Items.GetSize(); i++)
		AddString(Items[i]);

	// Get the maximum width of the text strings
	int nMaxLength = 0;
	CClientDC dc(GetParent());
	CFont* pOldFont = dc.SelectObject(pParent->GetFont());

	for (i = 0; i < Items.GetSize(); i++)
		nMaxLength = max(nMaxLength, dc.GetTextExtent(Items[i]).cx);

	nMaxLength += (::GetSystemMetrics(SM_CXVSCROLL) + dc.GetTextExtent(_T(" ")).cx*2);
	dc.SelectObject(pOldFont);

    if (nMaxLength > rect.Width())
	    rect.right = rect.left + nMaxLength;

	// Resize the edit window and the drop down window
	MoveWindow(rect);

	SetFont(pParent->GetFont());
	SetItemHeight(-1, nHeight);

	SetDroppedWidth(nMaxLength);
	SetHorizontalExtent(0); // no horz scrolling

	// Set the initial text to m_sInitText
	if (SelectString(-1, m_sInitText) == CB_ERR)
		SetWindowText(m_sInitText);		// No text selected, so restore what was there before

    // Subclass the combobox edit control if style includes CBS_DROPDOWN
    if ((dwStyle & CBS_DROPDOWNLIST) != CBS_DROPDOWNLIST)
    {
        m_edit.SubclassDlgItem(IDC_COMBOEDIT, this);
 	    SetFocus();
        switch (nFirstChar)
        {
            case VK_LBUTTON:
            case VK_RETURN:   m_edit.SetSel((int)_tcslen(m_sInitText), -1); return;
            case VK_BACK:     m_edit.SetSel((int)_tcslen(m_sInitText), -1); break;
            case VK_DOWN:
            case VK_UP:
            case VK_RIGHT:
            case VK_LEFT:
            case VK_NEXT:
            case VK_PRIOR:
            case VK_HOME:
            case VK_END:      m_edit.SetSel(0,-1); return;
            default:          m_edit.SetSel(0,-1);
        }
        SendMessage(WM_CHAR, nFirstChar);
    }
    else
 	    SetFocus();
}
示例#14
0
LONG_PTR ListBox::SelectString(CTSTRING &tsFind, INT_PTR iStart) {

  return SelectString(tsFind.c_str(), iStart);
}
示例#15
0
CInPlaceList::CInPlaceList(CWnd* pParent, CRect& rect, DWORD dwStyle, UINT nID,
                           int nRow, int nColumn, 
                           COLORREF crFore, COLORREF crBack,
						   IEnumerator<tstring> *items, CString sInitText, 
						   UINT nFirstChar)
{
    m_crForeClr = crFore;
    m_crBackClr = crBack;

	m_nNumLines = 20;
	m_sInitText = sInitText;
 	m_nRow		= nRow;
 	m_nCol      = nColumn;
 	m_nLastChar = 0; 
	m_bExitOnArrows = FALSE; //(nFirstChar != VK_LBUTTON);	// If mouse click brought us here,

	// Create the combobox
 	DWORD dwComboStyle = WS_BORDER|WS_CHILD|WS_VISIBLE|WS_VSCROLL| CBS_SORT |
 					     CBS_AUTOHSCROLL | dwStyle;
	int nHeight = rect.Height();
	rect.bottom = rect.bottom + m_nNumLines*nHeight + ::GetSystemMetrics(SM_CYHSCROLL);
	if (!Create(dwComboStyle, rect, pParent, nID)) return;

	// Add the strings	
	tstring item;
	items->Reset();
	while(items->MoveNext(item))
	{
		AddString(item.c_str());
	}		

	SetFont(pParent->GetFont());
	SetItemHeight(-1, nHeight);

    int nMaxLength = GetCorrectDropWidth();
    /*
    if (nMaxLength > rect.Width())
	    rect.right = rect.left + nMaxLength;
	// Resize the edit window and the drop down window
	MoveWindow(rect);
    */

	SetDroppedWidth(nMaxLength);

	SetHorizontalExtent(0); // no horz scrolling

	// Set the initial text to m_sInitText
    if (::IsWindow(m_hWnd) && SelectString(-1, m_sInitText) == CB_ERR) 
		SetWindowText(m_sInitText);		// No text selected, so restore what was there before

    ShowDropDown();

    // Subclass the combobox edit control if style includes CBS_DROPDOWN
    if ((dwStyle & CBS_DROPDOWNLIST) != CBS_DROPDOWNLIST)
    {
        m_edit.SubclassDlgItem(IDC_COMBOEDIT, this);
 	    SetFocus();
        switch (nFirstChar)
        {
            case VK_LBUTTON: 
            case VK_RETURN:   m_edit.SetSel((int)_tcslen(m_sInitText), -1); return;
            case VK_BACK:     m_edit.SetSel((int)_tcslen(m_sInitText), -1); break;
            case VK_DOWN: 
            case VK_UP:   
            case VK_RIGHT:
            case VK_LEFT:  
            case VK_NEXT:  
            case VK_PRIOR: 
            case VK_HOME:  
            case VK_END:      m_edit.SetSel(0,-1); return;
            default:          m_edit.SetSel(0,-1);
        }
        SendMessage(WM_CHAR, nFirstChar);
    }
    else
 	    SetFocus();
}
示例#16
0
/////////////////////////////////////////////////////////////////////////////
// PSOrdersTab message handlers
void PSOrdersTab::AddThisString(CString str)
{
	AddString(str);
	int nrItems = GetCount();
	SelectString(nrItems - 1);
}
示例#17
0
BOOL CSearchBox::PreTranslateMessage(MSG* pMsg)
{
	if( pMsg->message == WM_KEYDOWN )
	{
		if( IsWantChar( pMsg->wParam ) )
		{
			OnChangeStatus( pMsg->wParam, pMsg->lParam, TRUE );
			return TRUE;
		}
		if( VK_RETURN == pMsg->wParam )
		{
			m_bDoNothing	=	TRUE;
			m_hwndLastFocus	=	NULL;
			m_bSegmentEnd	=	TRUE;

			CString	strCommand;
			GetWindowText( strCommand );
			int nSel = SelectString( 0, strCommand );
			ShowDropDown( FALSE );
			SetCurSel( nSel );
			
			// Show Graph View
			if( CB_ERR != nSel && m_bShowOnSel )
			{
				DWORD	dwData	=	GetItemData( nSel );
				CView * pView = AfxGetStaticDoc()->GetActiveView();
				if( dwData & SEARCHBOX_SIGNBIT_STT )
					AfxShowStockTech( dwData & ~SEARCHBOX_SIGNBIT_STT ); 
				else if( dwData & SEARCHBOX_SIGNBIT_ACCE )
					AfxExecuteAccelerator( dwData & ~SEARCHBOX_SIGNBIT_ACCE );
				else if( IsCTRLpressed() )
					AfxShowStockBase( dwData, FALSE );
				else if( pView && pView->IsKindOf( RUNTIME_CLASS(CRealTimeView) ) )
					AfxShowStockRealTime( dwData, FALSE );
				else
					AfxShowStockGraph( dwData, FALSE );
			}
			else if( CB_ERR == nSel && m_bShowOnSel )
			{
				AfxShowStockGraph( strCommand );
			}
			else
				SetCurrentWindowText( );

			m_bDoNothing	=	FALSE;
			if( m_bAutoHide )
				SetWindowPos( NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_HIDEWINDOW );
			return TRUE;
		}
		else if( VK_ESCAPE == pMsg->wParam )
		{
			m_bDoNothing	=	TRUE;
			if( m_hwndLastFocus )
				::SetFocus( m_hwndLastFocus );
			m_hwndLastFocus	=	NULL;
			m_bSegmentEnd	=	TRUE;

			CString	strCommand;
			GetWindowText( strCommand );
			int nSel = SelectString( 0, strCommand );
			ShowDropDown( FALSE );
			SetCurSel( nSel );

			SetCurrentWindowText( );
			m_bDoNothing	=	FALSE;

			if( m_bAutoHide )
				SetWindowPos( NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_HIDEWINDOW );
			return TRUE;
		}
	}

	return CComboBox::PreTranslateMessage(pMsg);
}