message handling for a popup window
-
I create a list box as a popup window with parent as NONE and display it below a combo box. (This is imitation of intellisearch IE or IAutoComplete in WTL) The creation of the listbox looks like this
CMyComboBox::CreateListbox() { BOOL bRet = _list.CreateEx(0, _T("ComboLBox"), _T(""), WS_POPUP | WS_VISIBLE | WS_BORDER | WS_VSCROLL | LBS_NOTIFY, clientRect.left, clientRect.top, clientRect.Width(), clientRect.Height(), this->GetSafeHwnd(), //this is the combobox control's hwnd// NULL, NULL); }
I display this listbox when user starts typing some text in the combobox. I add the filtered strings as per the text to this listbox. There are two problems 1. I am trapping all the messages send to Listbox in its windowproc. I find that the first time I display this listbox, I am able to see LBN_SELCHANGE (or other listbox specific messages) being trapped in Windowproc. But they are sent only once. The next time when I try to change any selection, LBN_SELCHANGE is not sent/trapped (I don't know where this message goes). Although the basic messages - LBUTTON_DOWN/UP, KEY_DOWN/UP are being sent to the Listbox. I intend to write something like below, but LBN_SELCHANGE is caught only once.LRESULT CAutoCompListBox::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case LBN_SELCHANGE: { //Send this message to the combobox with the selected text // as argument }break;
Does the question make sense? or its too vague? :~ 2. I need to find a decent way to send the listbox messages to the combobox. Since the combobox is not at all related to Listbox here, I may have to resort to registering a callback in the Listbox to handle the messages. Is there any other way to handle the messages? Thanks first of all for reading the question. Many many thanks if you got some answersEvil triumphs when good people sit quiet...
-
I create a list box as a popup window with parent as NONE and display it below a combo box. (This is imitation of intellisearch IE or IAutoComplete in WTL) The creation of the listbox looks like this
CMyComboBox::CreateListbox() { BOOL bRet = _list.CreateEx(0, _T("ComboLBox"), _T(""), WS_POPUP | WS_VISIBLE | WS_BORDER | WS_VSCROLL | LBS_NOTIFY, clientRect.left, clientRect.top, clientRect.Width(), clientRect.Height(), this->GetSafeHwnd(), //this is the combobox control's hwnd// NULL, NULL); }
I display this listbox when user starts typing some text in the combobox. I add the filtered strings as per the text to this listbox. There are two problems 1. I am trapping all the messages send to Listbox in its windowproc. I find that the first time I display this listbox, I am able to see LBN_SELCHANGE (or other listbox specific messages) being trapped in Windowproc. But they are sent only once. The next time when I try to change any selection, LBN_SELCHANGE is not sent/trapped (I don't know where this message goes). Although the basic messages - LBUTTON_DOWN/UP, KEY_DOWN/UP are being sent to the Listbox. I intend to write something like below, but LBN_SELCHANGE is caught only once.LRESULT CAutoCompListBox::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case LBN_SELCHANGE: { //Send this message to the combobox with the selected text // as argument }break;
Does the question make sense? or its too vague? :~ 2. I need to find a decent way to send the listbox messages to the combobox. Since the combobox is not at all related to Listbox here, I may have to resort to registering a callback in the Listbox to handle the messages. Is there any other way to handle the messages? Thanks first of all for reading the question. Many many thanks if you got some answersEvil triumphs when good people sit quiet...
misha_grewal wrote:
LRESULT CAutoCompListBox::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case LBN_SELCHANGE: {
[LBN_SELCHANGE^] is a notification message sent through WM_COMMAND message. Correct it and check, later we discuss for the decent way.
misha_grewal wrote:
But they are sent only once
Actually you caught the WM_CREATE ( == 1 == LBN_SELCHANGE) message which is send only once.
modified on Monday, April 28, 2008 10:35 AM
-
misha_grewal wrote:
LRESULT CAutoCompListBox::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case LBN_SELCHANGE: {
[LBN_SELCHANGE^] is a notification message sent through WM_COMMAND message. Correct it and check, later we discuss for the decent way.
misha_grewal wrote:
But they are sent only once
Actually you caught the WM_CREATE ( == 1 == LBN_SELCHANGE) message which is send only once.
modified on Monday, April 28, 2008 10:35 AM
Thanks a ton..
Rajkumar R wrote:
Actually you caught the WM_CREATE ( == 1 == LBN_SELCHANGE) message which is send only once.
Yes, I think thats what I was catching.. The windowproc of the list box is getting all the WM messages like WM_KEYDOWN or LBUTTONUP. But a message like LBN_SELCHANGE is never caught in windowproc. why is it so? WM_COMMAND is sent to a parent of a window and the wparam has the message id. In this case, the list box doesn't have any parent as such, so you never receive WM_COMMAND messages
Evil triumphs when good people sit quiet...
-
Thanks a ton..
Rajkumar R wrote:
Actually you caught the WM_CREATE ( == 1 == LBN_SELCHANGE) message which is send only once.
Yes, I think thats what I was catching.. The windowproc of the list box is getting all the WM messages like WM_KEYDOWN or LBUTTONUP. But a message like LBN_SELCHANGE is never caught in windowproc. why is it so? WM_COMMAND is sent to a parent of a window and the wparam has the message id. In this case, the list box doesn't have any parent as such, so you never receive WM_COMMAND messages
Evil triumphs when good people sit quiet...
misha_grewal wrote:
the list box doesn't have any parent as such
ComboBox is the parent which you already set in CreateEx and get Notified since you set WM_NOTIFY, Any way since you are using MFC use ON_CONTROL_REFLECT to get the notification to the ListBox itself, Add handler to ListBox class to allow wizard to put ON_CONTROL_REFLECT macros.
modified on Tuesday, April 29, 2008 5:00 AM