【VC开源代码栏目提醒】:网学会员--在 VC开源代码编辑为广大网友搜集整理了:AutoComplete.cpp绩等信息,祝愿广大网友取得需要的信息,参考学习。
// AutoComplete.cpp : implementation file
//
#include "stdafx.h"
#include "QueryComboBox.h"
#include "AutoComplete.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// AutoComplete
AutoComplete::AutoComplete()
{
}
AutoComplete::~AutoComplete()
{
}
BEGIN_MESSAGE_MAP(AutoComplete, CComboBox)
//{{AFX_MSG_MAP(AutoComplete)
ON_CONTROL_REFLECT(CBN_EDITUPDATE, OnEditupdate)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// AutoComplete message handlers
void AutoComplete::OnEditupdate()
{
// TODO: Add your control notification handler code here
if(!m_bAutoComplete)return;
CString str;
GetWindowText(str);
int nLength=str.GetLength();
DWORD dwCurSel=GetEditSel();
DWORD dStart =LOWORD(dwCurSel);
DWORD dEnd =HIWORD(dwCurSel);
if(SelectString(-1,str)==CB_ERR)
{
SetWindowText(str);
if(dwCurSel!=CB_ERR)
SetEditSel(dStart,dEnd);
}
GetWindowText(str);
if(dEnd < nLength && dwCurSel!=CB_ERR)
SetEditSel(dStart,dEnd);
else
SetEditSel(nLength,-1);
}
BOOL AutoComplete::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
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);
}