|
-
June 15th, 2009, 04:20 AM
#1
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?
-
June 15th, 2009, 04:28 AM
#2
Re: ComboBox as child of a ListCtrl in a FormView
Did you try to handle it in the CListCtrl derived class?
Victor Nijegorodov
-
June 15th, 2009, 04:36 AM
#3
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.
-
June 15th, 2009, 04:38 AM
#4
Re: ComboBox as child of a ListCtrl in a FormView
 Originally Posted by maglite
I avoided deriving my own list control.
Why?
Victor Nijegorodov
-
June 15th, 2009, 04:48 AM
#5
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...
Last edited by maglite; June 15th, 2009 at 04:50 AM.
-
June 15th, 2009, 05:04 AM
#6
Re: ComboBox as child of a ListCtrl in a FormView
 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.
 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.
 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.)
Victor Nijegorodov
-
June 15th, 2009, 05:20 AM
#7
Re: ComboBox as child of a ListCtrl in a FormView
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. 
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.
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?
Last edited by maglite; June 15th, 2009 at 05:23 AM.
-
June 15th, 2009, 05:39 AM
#8
Re: ComboBox as child of a ListCtrl in a FormView
Yiou can get some ideas from this article
Victor Nijegorodov
-
June 15th, 2009, 05:45 AM
#9
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|