MFC组合框,灼热字体列表
MFC combobox, searcing font list
如何使用A-z keydown事件在组合框中实现搜索?更糟糕的是,工具栏中有一个CMFCToolBarButton。
这是带有字体列表的组合B。只需按下键选择一个即可。非常感谢。
这是解决方案。工作良好。
void C_dropDlg::OnEditUpdate()
{
if (!m_bAutoComplete)
return;
// Get the text in the edit box
CString str;
MyDropDown.GetWindowText(str);
int nLength = str.GetLength();
// Currently selected range
DWORD dwCurSel = MyDropDown.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 (MyDropDown.SelectString(-1, str) == CB_ERR)
{
SetWindowText(str); // No text selected, so restore what was there before
if (dwCurSel != CB_ERR)
MyDropDown.SetEditSel(dStart, dEnd); //restore cursor postion
}
// Set the text selection as the additional text that we have added
if (dEnd < nLength && dwCurSel != CB_ERR)
MyDropDown.SetEditSel(dStart, dEnd);
else
MyDropDown.SetEditSel(nLength, -1);
}
// TODO: Add your control notification handler code here
BOOL C_dropDlg::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;
if(nVirtKey == VK_ESCAPE)
{
}
}
return CDialogEx::PreTranslateMessage(pMsg);
}
我已经失去了与解决方案的链接,但感谢作者。
不要忘记在基类中定义m_AutoComplete!
相关文章:
- Pybind11:将元组列表从Python传递到C++
- 从链接列表c++中删除一个项目
- 如何(从固定列表中)选择一个数字序列,该序列将与目标数字相加
- 在C++中测量postscript字体宽度
- C++如何通过用户输入删除列表元素
- 读取文件的最后一行并输入到链接列表时出错
- 复制列表初始化的隐式转换的等级是多少
- LNK2038、MSVS2017 MAGMA的原因列表
- 不能在初始值设定项列表中将非常量表达式从类型 'int' 缩小到'unsigned long long'
- 没有为自己的结构调用列表推回方法
- 使用简单类型列表实现的指数编译时间.为什么
- 一对向量构造函数:初始值设定项列表与显式构造
- 如何获取具有 Freetype2 的真正类型字体支持的代码点列表 C++
- MFC组合框,灼热字体列表
- 如何使用 fontconfig 获取字体列表 (C/C++)
- QListView或QListWidget中的Qt c++字体列表,并将它们表示为复选框
- 获得可用字体列表的跨平台方式
- QML列表视图在字体更改时显示统一的宽度
- Qt c++:字体族的静态列表
- Qt-我在哪里可以找到我可以使用的字体列表