Reputation: 3805
I am looking for Search box control something like this
Are there any controls available in the MFC or we need to create our own,
any example / refrence code is there that we can refer, I tried googling, but i am more getting CEditComboBox example rather then this type of control.
Thanks in Advance
Upvotes: 0
Views: 2893
Reputation: 25
I also needed a feature such as this one, except for searching in a CListBox. Here is what I managed to do using the EN_CHANGE notification when the user types in the editbox :
void CRequestDlg::OnEnChangeEditSearch() { UpdateData(TRUE); string sEdit = m_sSearch.GetBuffer(m_sSearch.GetLength()); string sTmp; for ( int n_pos = 0; n_pos < m_lbRequest.GetCount(); n_pos++ ) { CString temp; m_lbRequest.GetText(n_pos, temp); sTmp = string(temp); if ( sTmp.find(m_sSearch) != string::npos ) { m_lbRequest.SetCurSel(n_pos); break; } } UpdateData(FALSE); }
Upvotes: 0
Reputation: 3466
If you are using VS2008 SP1 or above, you have CMFCEditBrowseCtrl.
It's an edit control with a button. It has built-in "browse for file" or "browse for folder" actions when you press the button, but you can create your own custom action (search), and also customize the button image.
Check the documentation on EnableBrowseButton and OnBrowse to see how to customize the action, and SetBrowseButtonImage to customize the image.
Upvotes: 2