ComboBox as child of a ListCtrl in a FormView
Hello!
In an application I have a Form View with a list control (m_ctrlList) in it, among others. The list control is set to report style. There is also a combo box that is supposed to show up, whenever I click particular items in the list control. The combo box is hence created as a child of the list control.
Code:
dwStyle = WS_BORDER|WS_CHILD|WS_VISIBLE|CBS_DROPDOWNLIST;
m_ctrlCombo.Create(dwStyle, r, &m_ctrlList, IDC_INPUT_COMBO);
So far so good. The combo box shows where and when i want it.
Now I want to handle a selection change of the combo box within the form view class and there's my problem: Since the combo box is a child of the list control the form view class doesn't get a message when the selection is changed...
I inserted a message map entry like this:
Code:
ON_CBN_SELCHANGE(IDC_INPUT_COMBO, &CInputView::OnCbnSelchangeInputCombo)
Any ideas?
Re: ComboBox as child of a ListCtrl in a FormView
Did you try to handle it in the CListCtrl derived class?
Re: ComboBox as child of a ListCtrl in a FormView
I avoided deriving my own list control. The combo box is also a member of the CFormView derived class but created as the list control's child.
Re: ComboBox as child of a ListCtrl in a FormView
Quote:
Originally Posted by
maglite
I avoided deriving my own list control.
Why? :confused:
Re: ComboBox as child of a ListCtrl in a FormView
Well, I thought it would save me some work - obviously without thinking about the trouble it could get me in.
But that's not the whole reason. I have a doc-view application with multiple views which communicate with each other. So, if I change the combo boxes selection I need the form view to recognize it and call the document's UpdateAllViews method. Therefore I thought it would be more comfortable to just let the combo box be a member of the view and directly handle a selection change...
Re: ComboBox as child of a ListCtrl in a FormView
Quote:
Originally Posted by
maglite
Well, I thought it would save me some work - obviously without thinking about the trouble it could get me in.
What *trouble* do you mean? I never had any trouble while using classes derived from MFC control classes.
Quote:
Originally Posted by
maglite
... I have a doc-view application with multiple views which communicate with each other. So, if I change the combo boxes selection I need the view to send a message to the other views.
Hmmm... It is not the best way to communicate between the Views.
The best (and it is the standard one) is using CDocument::UpdateAllViews method.
Quote:
Originally Posted by
maglite
... I thought it would be more comfortable to just let the combo box be a member of the view and directly handle a selection change...
But being the *member* of the View does NOT mean being its *child* which is needed to send the notifications to the View (notifications are sent to the parent window.)
Re: ComboBox as child of a ListCtrl in a FormView
Quote:
What *trouble* do you mean? I never had any trouble while using classes derived from MFC control classes.
I meant the trouble that results in NOT deriving my own class but doing it the way I did. ;)
Quote:
Hmmm... It is not the best way to communicate between the Views.
The best (and it is the standard one) is using CDocument::UpdateAllViews method.
Using CDocument::UpdateAllViews is what I meant by communication. I should have been more exact.
Quote:
But being the *member* of the View does NOT mean being its *child* which is needed to send the notifications to the View (notifications are sent to the parent window.)
I'm aware of this fact and already identified it as my problem in the initial post.
So your suggestion is to derive my own list control and let it send a message to the view, when the combo's selection is changed?
Re: ComboBox as child of a ListCtrl in a FormView
Yiou can get some ideas from this article
Re: ComboBox as child of a ListCtrl in a FormView
Alright. Thank you for now. I'm going to derive my own list control and let you know if it worked.