⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 autoco~1.cpp

📁 visual c++ 时尚编程百例 全部源代码
💻 CPP
字号:
// AutoComboBox.cpp : implementation file
//

#include "stdafx.h"
#include "ACtoCombo.h"
#include "AutoComboBox.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAutoComboBox

CAutoComboBox::CAutoComboBox()
{
	m_bAutoComplete=TRUE;
}

CAutoComboBox::~CAutoComboBox()
{
}


BEGIN_MESSAGE_MAP(CAutoComboBox, CComboBox)
	//{{AFX_MSG_MAP(CAutoComboBox)
	ON_CONTROL_REFLECT(CBN_EDITUPDATE, OnEditupdate)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAutoComboBox message handlers

void CAutoComboBox::OnEditupdate() 
{
if(!m_bAutoComplete)
return;
CString str;
GetWindowText(str);
int nLength=str.GetLength();
DWORD dwCurSel=GetEditSel();
WORD dStart=LOWORD(dwCurSel);
WORD 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 CAutoComboBox::PreTranslateMessage(MSG* pMsg) 
{
if(	pMsg->message==WM_KEYDOWN)
{
	m_bAutoComplete=TRUE;
	int nVirKey=(int)pMsg->wParam;
	if(nVirKey==VK_DELETE||nVirKey==VK_BACK)
		m_bAutoComplete=FALSE;
}
	return CComboBox::PreTranslateMessage(pMsg);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -