|
When we type continuously in combo box it will auto-fill the remaining text. But if we take some time interval to type it won't auto-fill the correct one.
For Example if suppose i need "raam" to be filled but when i type "ra" and take some time it means not too much just 2 second and then i type "a" i.e; "raa" it won't show "raam" it will show the word which is starting with the letter "a" i.e; for example "Arun" how to solve this....
|
|
|
|
|
Hi,
Can i use this in two seperate dialogs in the same applcation.
Because i uses it in firstdailog and works.
But when i include in another dailog it shows unhandled exception in disassemply.
Just i added as like first dailog.
I created membervariable for all combobox and changed CCombobox variable type to CComboCompletion.
After that,when i debug it shows unhandled exception.
Wat can i do to use this class in another dailog.
Anu
|
|
|
|
|
I am not sure if anyone has pointed this out, but with the demo project you cant type a capital 'B' to begin with. 'branches' starts to come up. So say I want to type in 'Boy'. I really cant just type it in. I would have to type 'bB' and then delete the 'b' and then key in 'oy'.
Chris
|
|
|
|
|
Yes it's true!, it came from what CComboBox is case-insesitive in replace we must move to CComboBoxEx but that mean some change in the code. here in Codeproject are other's projects that support case-sensitive completion.
----LOLO----
-------------
<<argentina>>
-------------
|
|
|
|
|
I search and the easiest way to do it what i find is modifying the OnEditUpdate method. In the next code the only thing i do is search for the word(caseinsensitive)with the SelecString method and then compare it with the text i have entered, using the CString compare thath are Case sensitive
void CComboCompletion::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
int inicio = -1;
int posicion = -1;
posicion = SelectString(inicio, str);
do
{
if (posicion == CB_ERR)
{
SetWindowText(str); // No text selected, so restore what was
//there before
if (dwCurSel != CB_ERR)
SetEditSel(dStart, dEnd);//restore cursor position
break;
}
else
{
CString text_in_combo;
GetWindowText(text_in_combo);
if(str.Compare(text_in_combo.Left(str.GetLength()))==0) //check only the first letters
{
break;
}
else
{
inicio = posicion; //Set a new start point for the search
posicion =SelectString(inicio, str);
if((posicion<=inicio)||(posicion == CB_ERR)) //and check that not are looping thru the list
{
SetWindowText(str); // No text selected, so restore what was there before
if (dwCurSel != CB_ERR)
SetEditSel(dStart, dEnd); //restore cursor postion
break;
}
}
}
}while(1);
// 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);
}
----LOLO----
-------------
<<argentina>>
-------------
|
|
|
|
|
this can be a stupid comment but it help me.
when the auto completion was on and the text are filling automaticly the combo box doesnt allow to pass the Return key to the dialog and i cant execute the default button(i have to click it) but after i type Backspace key it return to normality so i add the Return to the keys that disable the auto completion and pass it to the dialog handler.
so:
BOOL CComboCompletion::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_KEYDOWN)
{
m_bAutoComplete = TRUE;
int nVirtKey = (int) pMsg->wParam;
if (nVirtKey == VK_DELETE || nVirtKey == VK_BACK || nVirtKey == VK_RETURN)
m_bAutoComplete = FALSE;
}
return CComboBox::PreTranslateMessage(pMsg);
}
i hope it help somebody
----LOLO----
-------------
<<argentina>>
-------------
|
|
|
|
|
When i hit the "enter key" the whole dialog based application "controls" are vanished...
can you tell me any suggesion..
Regards,
Inba.G
-- modified at 11:30 Monday 20th February, 2006
|
|
|
|
|
Great Works,Can you complete it with C#? thanks a lot!
|
|
|
|
|
kv4000 wrote:
Can you complete it with C#? thanks a lot!
I just want to add my voice to this, since as a VB.NET programmer I can use C# code by converting it to VB but I'm really ignorant of C++ code.
It would really be helpful to me if it's not too much trouble to convert it to C#.
At the same time, what would be involved in incorporating the case-sensitive aspects as implemented by Paul S. Vickery? That would solve a lot of peoples' problems I'll bet!
Paul's project is here:
http://www.codeguru.com/Cpp/controls/combobox/article.php/c4957/
Thanks!!
|
|
|
|
|
:-Di have a litte problem that need show edit box of the combobox up and select matched string when match successful.
i have perform ShowDropDown function that seem don't quite well, i hope u can some advices to me, thank u.
|
|
|
|
|
i create CComboBox in IE Toolbar, everything work! except Backspace and Enter key. when i type text in edit control, i can't use backspace key to delete text, i must go to first text and use delete key. i use TranslateAcceleratorIO but it not work! Should i do?
and in my code i use AfxMessageBox to check my combobox get focus but it not show.
this's my code:
STDMETHODIMP CTQToolBarCtrl::TranslateAcceleratorIO(LPMSG lpMsg)
{
USES_CONVERSION;
if (m_comboBox.m_hWnd == ::GetFocus())
{
AfxMessageBox("bingo");
}
int nVirtKey = (int)(lpMsg->wParam);
if (VK_RETURN == nVirtKey)
{
lpMsg-> wParam= 0;
_variant_t varEmpty;
_variant_t varURL;
CString strURL;
this->m_comboBox.GetWindowText(strURL);
strURL = "http://www.thaiquest.com/news/thai/search.aspx?keyword=" + strURL;
varURL = (_bstr_t)strURL;
m_pParent->m_pIE->Navigate2(&varURL, &varEmpty, &varEmpty, &varEmpty, &varEmpty);
return S_OK;
}
else if (WM_KEYDOWN == lpMsg->message && nVirtKey == VK_TAB)
{
if (m_pParent) m_pParent->FocusChange(FALSE);
return S_FALSE;
}
else if ((WM_KEYUP == lpMsg->message || WM_KEYDOWN == lpMsg->message) &&
VK_BACK == nVirtKey || (VK_END <= nVirtKey && VK_DOWN >= nVirtKey) ||
VK_DELETE == nVirtKey)
{
rlaley...girl
|
|
|
|
|
i try to use PretranslateMessage function in my IE Toolbar combobox but it not work! when it add back the text that same prefix when i tryed to delete, i can't nothing happen. i don't know what's wrong. Help me pls!!!
rlaley...girl
|
|
|
|
|
Hello
I had the same problem when adding a combobox to my IE tool bar, but I was able to fix it. This is how I fixed it
in my TranslateAcceleratorIO I added
if( pMsg->message == WM_KEYDOWN )
{
switch (pMsg->wParam)
{
case VK_BACK:
if (SendMessage(pMsg->hwnd, WM_CHAR, (unsigned int)pMsg->wParam, pMsg->lParam) == 1)
return 0;
}
}
this should get the backspace working correctly u can do the same for the enter and other keys, in other words this forword the messeges to the child controller.
If u dont get any event on TranslateAcceleratorIO that mostly means that ur tool bar dont get the focuse or u didn't notify ur toolbar that is has the focuse. u can notify ur toolbar with handling the WM_PARENTNOTIFY message
wish that helps
|
|
|
|
|
Thanks ...
rlaley...girl
|
|
|
|
|
A very useful control, which I would like to extend by capturing right-clicks. I can capture the WM_RBUTTONDOWN/WM_RBUTTONUP messages in preTranslate message, which allows me to delete an item if it matches the Edit box contents. However, it would be much more useful to capture a right-click on the item in the list box.
I've tried using ClassWizard to put in a function for catching the WM_RBUTTONx messages, but the function never gets invoked by a click anywhere, not even the Edit box. Does the list box need to be subclassed, or is there a simpler way to achieve this?
Thanks,
Flic
|
|
|
|
|
Has anybody have solution for this.
|
|
|
|
|
Is it possible to adapt this to show the list of options, as it does in IE with auto completing text boxes?
|
|
|
|
|
Can someone help me get this code to also get a simple-style ComboBox to higlight the item from the listbox as the user types. I tried various ways of using SetCurSel() and SetTopIndex(). I want to also have the item appear at the top of the ComboBox.
Thanks.
Maxwell
|
|
|
|
|
I have used this completing combo box with delight for the last year. I just came upon a problem when I tried to close the drop down from the PreTranslateMessage() so that the user only had to push the Enter button once to do the default action of the enclosing dialog. Without this, one had to hit Enter once to close the drop down and then Enter again to do the OK button. I added the following (in PreTranslateMessage()):
// if we have the enter key, close the drop down here so that
// we only have to hit enter once
if(key == VK_RETURN) {
int iSelectedRow = GetCurSel();
int iCount = GetCount(); // shows as message in spy log
TRACE(_T("PreTranslate1::m_iSelectedRow=%d: iSelectedRow=%d\n")
, m_iSelectedRow, iSelectedRow);
ShowDropDown(FALSE);
}
iSelectedRow at this point is always returned as CB_ERR.
This ShowDropDown() now seems to trigger a CBN_ONSELCHANGE message because my OnSelChange() handler is triggered immediately after the ShowDropDown.
In the OnSelChange() handler, I also call GetCurSel() and get a valid number but not the one that had been set by the string recogniser.
I ran Spy on this, just logging the ComboBox messages with the following result:
...
<00033> 00000A14 S ..CB_SHOWDROPDOWN fShow:True
<00034> 00000A14 R ..CB_SHOWDROPDOWN lResult:True
<00035> 00000A14 S ..CB_SETCURSEL index:2
<00036> 00000A14 R ..CB_SETCURSEL lResult:0002
<00037> 00000A14 S ..CB_SETEDITSEL ichStart:2 ichEnd:65535
<00038> 00000A14 R ..CB_SETEDITSEL lResult:True
<00039> 00000A14 S CB_GETCURSEL
<00040> 00000A14 R CB_GETCURSEL index:CB_ERR
<00041> 00000A14 S CB_GETCOUNT
<00042> 00000A14 R CB_GETCOUNT cItems:15
<00043> 00000A14 S CB_SHOWDROPDOWN fShow:False
<00044> 00000A14 S ....CB_GETCURSEL
<00045> 00000A14 R ....CB_GETCURSEL index:1
<00046> 00000A14 S ....CB_GETCOUNT
<00047> 00000A14 R ....CB_GETCOUNT cItems:15
<00048> 00000A14 S ....CB_GETCURSEL
<00049> 00000A14 R ....CB_GETCURSEL index:1
Line <00035> shows me finding the unique match and selecting row 2. Note that there are two dots supposedly showing nesting level in front of the message.
Now I hit the Enter and line <00039> shows the GetCurSel() inside the PreTranslateMessage() returning a CB_ERR.
Next we see the ShowDropDown(false) and immediately after this the GetCurSel() call from within my OnSelChange() handler (no mention of the CBN_ONSELCHANGE message). The messages are preceded however with four dots!
At this point (line <00045>) the GetCurSel() returns a 1. Neither the 2 that was inserted at line <00036> or the CB_ERR.
Can anyone suggest a mechanism for this observed behaviour?
This problem is explained in more detail at the following URL:
http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=mfc&qid=20187773
Edward E.L. MItchell
Pharsight Corp.
(508)771-0806
500 Ocean St., Unit 134,
Hyannis, MA 02601
|
|
|
|
|
I have two ComboBoxes on my dialog, when I make a selection in Combo1 I fill Combo2 with relevant strings.
If I use the mouse to make my selection in Combo1, Combo2 is filled correctly if I use CComboBox and CComboCompletion.
If I use the keyboard to make my selections in Combo1, Combo2 is filled correctly only if I use CComboBox. When using CComboCompletion COmbo2 is empty.
I have tried CBN_SELENDOK, CBN_SELCHANGE and a few others I have forgotten and none of them get initiated when using the keyboard and CComboCompletion.
Any ideas on what else I can try or what I am doing wrong.
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
"Don't belong. Never join. Think for yourself. Peace"
- Victor Stone
|
|
|
|
|
Ask to Chris, Why don't work CComboCompletion.
I saw that class, that was written for Chris Maunder, but That class must to work because is a class derived from CComboBox, And when the application catch the OnSelChange message, it must to send the message to CComboBox.
Best Regards!!!
Carlos Antollini.
|
|
|
|
|
When I derieved my ComboBox from this ComboBox, the GetCurSel() does not return the selected index. It means that the SelectString does not set the index selected when used in your function Any solution ??
|
|
|
|
|
Great class, but nobody has replied to this problem so here is a simple work-around...
In your dialog OnOK, you normally have something like
m_index = m_combo.GetCurSel();
so instead you simply need to use
CString str;
m_combo.GetWindowText(str);
m_index = m_combo.FindString(0, str);
|
|
|
|
|
 Another work-around that allows to use GetCurSel()
void CComboCompletion::OnEditUpdate() <br />
{<br />
if (!m_bAutoComplete) <br />
return;<br />
<br />
CString str;<br />
GetWindowText(str);<br />
int nLength = str.GetLength();<br />
<br />
DWORD dwCurSel = GetEditSel();<br />
WORD dStart = LOWORD(dwCurSel);<br />
WORD dEnd = HIWORD(dwCurSel);<br />
<br />
int nOldSel = GetCurSel();<br />
int nNewSel = SelectString(-1, str);<br />
if (nNewSel == CB_ERR)<br />
{<br />
SetWindowText(str);
if (dwCurSel != CB_ERR)<br />
SetEditSel(dStart, dEnd);
}<br />
<br />
if (nNewSel != CB_ERR)<br />
PostMessage(CB_SETCURSEL, nNewSel, 0);
if (dEnd < nLength && dwCurSel != CB_ERR)<br />
PostMessage(CB_SETEDITSEL, 0, MAKELONG(dStart, dEnd));
else<br />
PostMessage(CB_SETEDITSEL, 0, MAKELONG(nLength, -1));
<br />
if (nNewSel != CB_ERR && nNewSel != nOldSel)<br />
{<br />
CWnd* pParent = CWnd::GetParent();<br />
if (pParent != NULL && str.IsEmpty() == FALSE)<br />
pParent->PostMessage( WM_COMMAND, MAKEWPARAM( GetDlgCtrlID(), LBN_SELCHANGE), (LPARAM)GetSafeHwnd());<br />
}<br />
}
|
|
|
|
|
How can I use your code in a non-dialog based app, using a CComboBoxEx Class, and trap the CBN_EDITUPDATE message. I've tried this by using the create member of CComboBoxEx and for some reason the CBN_EDITUPDATE message is not being generated. How else can this be done?
|
|
|
|