CSliderCtrl notifications
ktm@ormec.com Friday, September 27, 1996 Environment: Win 95, VC++ 4.2 I have a dialog with a slider control in it. Using ClassWizard, I added handlers for the notification messages I was interested in. None of those methods are ever getting called! I used Spy++ to watch the window, and saw that no WM_NOTIFY messages are being sent at all! Instead, the CSliderCtrl window is getting window messages like WM_KILLFOCUS, WM_LBUTTONDOWN, WM_LBUTTONUP, etc. (instead of the NM_KILLFOCUS, NM_CLICK messages I expected). Do I need to add something to my code in order to ensure that the notification messages are actually sent? Or do I need to add something to the message map to handle the WM_ messages being sent to the control? Neither of the MFC samples (FIRE, CMNCTRLS) that use the slider control demonstrate notification messages for that control. I'd appreciate a good example. - Katy -- Katy Mulvey ktm@ormec.com Software Development Engineer ORMEC Systems 19 Linden Park; Rochester, NY 14625
ganeshs@nationwide.com Monday, September 30, 1996 Environment: Win 95, VC++ 4.2 > I have a dialog with a slider control in it. Using ClassWizard, I added > handlers for the notification messages I was interested in. To CSliderCtrl's message map? > None of those methods are ever getting called! I used Spy++ to watch the > window, and saw that no WM_NOTIFY messages are being sent at all! Instead, > the CSliderCtrl window is getting window messages like WM_KILLFOCUS, > WM_LBUTTONDOWN, WM_LBUTTONUP, etc. (instead of the NM_KILLFOCUS, NM_CLICK > messages I expected). Which is what should be happening, since a slider control RECEIVES Windows messages (like any Windows window) and SENDS notifications like NM_KILLFOCUS to it's parent, (like any child-window-control should...) the dialog-box window. > Do I need to add something to my code in order to ensure that the > notification messages are actually sent? Or do I need to add something to > the message map to handle the WM_ messages being sent to the control? Add your notification handlers to your dialog's message map, and everything should be just fine... / ___| / ___| __ _ _ __ ___ ___| | I do not speak for \___ \ | | _ / _` | '_ \ / _ \/ __| '_ \ Tata Unisys or ___) | | |_| | (_| | | | | __/\__ \ | | |Nationwide Ins. |____(_) \____|\__,_|_| |_|\___||___/_| |_|------------------
ktm@ormec.com Thursday, October 03, 1996 [Mini-digest: 3 responses] ganeshs@nationwide.com wrote: > Katy Mulveywrote: > > I have a dialog with a slider control in it. Using ClassWizard, I added > > handlers for the notification messages I was interested in. > > To CSliderCtrl's message map? No, to the dialog message map - that is, it ends up looking like: // From the .H file // Generated message map functions //{{AFX_MSG(CSliderDlg) //... afx_msg void OnKillfocusSlider1(NMHDR* pNMHDR, LRESULT* pResult); afx_msg void OnClickSlider1(NMHDR* pNMHDR, LRESULT* pResult); //}}AFX_MSG DECLARE_MESSAGE_MAP() // From the .CPP file BEGIN_MESSAGE_MAP(CSliderDlg, CDialog) //{{AFX_MSG_MAP(CSliderDlg) //... ON_NOTIFY(NM_KILLFOCUS, IDC_SLIDER1, OnKillfocusSlider1) ON_NOTIFY(NM_CLICK, IDC_SLIDER1, OnClickSlider1) //}}AFX_MSG_MAP END_MESSAGE_MAP() > > ... > Which is what should be happening, since a slider control RECEIVES > Windows messages (like any Windows window) and SENDS notifications like > NM_KILLFOCUS to it's parent, (like any child-window-control should...) > the dialog-box window. Yes, I can see that I was confused here. But if I trace all messages in the application, no WM_NOTIFY or WM_NOTIFYPARENT messages are ever sent or recieved by any window in the application. (For testing, it's just a simple dialog with a slider control and the OK and Cancel buttons.) > > Do I need to add something to my code in order to ensure that the > > notification messages are actually sent? Or do I need to add something to > > the message map to handle the WM_ messages being sent to the control? > > Add your notification handlers to your dialog's message map, and > everything should be just fine... Unfortunately, this is not the case. Katy ktm@ormec.com -----From: ganeshs@nationwide.com What I meant here was, add notification handlers for _WHATEVER_ messages a slider control sends to it's parent. The documentation clearly states that a slider receives WM_HSCROLL or WM_VSCROLL messages, depending on it's orientation. In effect, it's quite similar to a scrollbar control (or a scrollbar, for that matter). You need to add a WM_HSCROLL or WM_VSCROLL handler to your dialog. / ___| / ___| __ _ _ __ ___ ___| | I do not speak for \___ \ | | _ / _` | '_ \ / _ \/ __| '_ \ Tata Unisys or ___) | | |_| | (_| | | | | __/\__ \ | | |Nationwide Ins. |____(_) \____|\__,_|_| |_|\___||___/_| |_|------------------ -----From: ktm@ormec.com Katy Mulvey (ktm@ormec.com) wrote: > Environment: Win 95, VC++ 4.2 > > I have a dialog with a slider control in it. Using ClassWizard, I added > handlers for the notification messages I was interested in. > [... etc.] I've been corresponding with S. Ganesh (ganeshs@nationwide.com), who responded to the original message, and have cleared up some of my confusion (but not all of it). Here's my current situation: When you insert a slider control into a dialog template, ClassWizard allows you to add ON_NOTIFY handlers for the common notifications. (e.g., the ones that start with NM_, like NM_KILLFOCUS, NM_CLICK). Additionally, the slider control sends either WM_HSCROLL or WM_VSCROLL messages to the dialog box when the slider is moved. In this case, I'm interested in knowing when the slider control loses focus, so using the class wizard, I added an ON_NOTIFY for NM_KILLFOCUS. However, using Spy++, I can see that when the slider control loses focus, it gets a WM_KILLFOCUS message, but does not send a WM_NOTIFY message to the dialog, and so my handler never gets called. So I'm left with the questions: Does a slider control send WM_NOTIFY messages under the proper circumstances? If so, what are those circumstances? If not, why does ClassWizard think that it does? If I have a slider control in my dialog, how can I know when it loses focus? Katy -- Katy Mulvey ktm@ormec.com Software Development Engineer ORMEC Systems 19 Linden Park; Rochester, NY 14625
ganeshs@nationwide.com Monday, October 07, 1996 Environment: Win 95, VC++ 4.2 > So I'm left with the questions: > Does a slider control send WM_NOTIFY messages under the proper > circumstances? > If so, what are those circumstances? > If not, why does ClassWizard think that it does? > If I have a slider control in my dialog, how can I know when it loses > focus? Add a WM_KILLFOCUS handler to a CSliderCtrl-derived class, and SubClass the dialog slider control... If you so prefer, Post a WM_NOTIFY message to your parent-dialog in the KillFocus handler... / ___| / ___| __ _ _ __ ___ ___| | I do not speak for \___ \ | | _ / _` | '_ \ / _ \/ __| '_ \ Tata Unisys or ___) | | |_| | (_| | | | | __/\__ \ | | |Nationwide Ins. |____(_) \____|\__,_|_| |_|\___||___/_| |_|------------------
| Вернуться в корень Архива |