|
|
|
|
Forum
Please
Log In
to post a new message or reply to an existing one. If you are not registered, please
register.
NOTE: Some forums may be read-only if you are not currently subscribed to
our technical support services.
Subject |
Author |
Date |
|
Cyndi Chatman
|
Nov 13, 2007 - 3:37 PM
|
I am using version 2.62. In the call to OnSetFocus() for a CExtComboBox, I am calling SetBkColor to set the background color of the combo box. It does not appear to have any affect, it remains white. I am making the same function call (SetBkColor) on CExtEdit controls and it is working. Is this not supported for CExtComboBox?
|
|
Technical Support
|
Nov 16, 2007 - 12:12 PM
|
The CExtComboBox class has a built-in auto complete feature which is turned on by default (the m_bEnableAutoComplete property). So you may want not to use your class.
|
|
Cyndi Chatman
|
Nov 15, 2007 - 12:29 PM
|
Thanks. I have upgraded to version 2.81 and that fixed the problem. Now I have another small problem. I have a custom combo box class named CAutoCompleteComboBox. The class overrides the CBN_EDITUPDATE handler; that is
ON_CONTROL_REFLECT(CBN_EDITUPDATE, OnEditUpdate)
While the user is typing, this handler finds the first string that starts with the characters the user has typed so far. I changed my CAutoCompleteComboBox from a standard CComboBox to a CExtComboBox and the functionality stopped working. Is CExtComboBox overriding this as well? My question is: how can I get the windows style of the CExtComboBox (as far as how it looks and the ability to set the back ground color), without overriding my handlers?
Here is a copy of my source.
Header file:
#if !defined(AFX_COMBOBOXEX_H__115F422E_5CD5_11D1_ABBA_00A0243D1382__INCLUDED_) #define AFX_COMBOBOXEX_H__115F422E_5CD5_11D1_ABBA_00A0243D1382__INCLUDED_
#if _MSC_VER >= 1000 #pragma once #endif // _MSC_VER >= 1000
// ComboBoxEx.h : header file //
///////////////////////////////////////////////////////////////////////////// // CAutoCompleteComboBox window
class CAutoCompleteComboBox : public CExtComboBox { // Construction public: CAutoCompleteComboBox();
// Attributes public:
// Operations public:
// Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CAutoCompleteComboBox) public: virtual BOOL PreTranslateMessage(MSG* pMsg); //}}AFX_VIRTUAL
// Implementation public: virtual ~CAutoCompleteComboBox();
BOOL m_bAutoComplete;
// Generated message map functions protected: //{{AFX_MSG(CAutoCompleteComboBox) afx_msg void OnEditUpdate(); //}}AFX_MSG
DECLARE_MESSAGE_MAP() };
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_COMBOBOXEX_H__115F422E_5CD5_11D1_ABBA_00A0243D1382__INCLUDED_)
Source file:
// ComboBoxEx.cpp : implementation file
#include "stdafx.h" #include "AutoCompleteComboBox.h"
#ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif
///////////////////////////////////////////////////////////////////////////// // CAutoCompleteComboBox
CAutoCompleteComboBox::CAutoCompleteComboBox() { m_bAutoComplete = TRUE; }
CAutoCompleteComboBox::~CAutoCompleteComboBox() { }
BEGIN_MESSAGE_MAP(CAutoCompleteComboBox, CExtComboBox) //{{AFX_MSG_MAP(CAutoCompleteComboBox) ON_CONTROL_REFLECT(CBN_EDITUPDATE, OnEditUpdate) //}}AFX_MSG_MAP END_MESSAGE_MAP()
///////////////////////////////////////////////////////////////////////////// // CAutoCompleteComboBox message handlers
BOOL CAutoCompleteComboBox::PreTranslateMessage(MSG* pMsg) { // Need to check for backspace/delete. These will modify the text in // the edit box, causing the auto complete to just add back the text // the user has just tried to delete.
if (pMsg->message == WM_KEYDOWN) { m_bAutoComplete = TRUE;
int nVirtKey = (int) pMsg->wParam; if (nVirtKey == VK_DELETE || nVirtKey == VK_BACK) m_bAutoComplete = FALSE; }
return CComboBox::PreTranslateMessage(pMsg); }
void CAutoCompleteComboBox::OnEditUpdate() { // if we are not to auto update the text, get outta here if (!m_bAutoComplete) 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); }
|
|
Technical Support
|
Nov 15, 2007 - 3:15 AM
|
The incorrect background color in CExtComboBoxBase was fixed in Prof-UIS 2.81. Here are the lines from version history:
The text color and background color of the edit part of the CExtComboBoxBase are now synchronized with the colors you can set for the combo box by using the CExtComboBoxBase::SetBkColor() and CExtComboBoxBase::SetTextColor()<?code> methods. This was achieved by adding <code>OnQueryBackColor() and OnQueryTextColor() virtual methods to the CExtEditBase class.
|
|