Trackbar Notifications
- I am trying to get some notification messages when a trackbar slider is moved and when the slider is released by releasing a mouse press.
I am already getting the NM_RELEASEDCAPTURE notification when the mouse button is released. I cannot figure out what notification is sent when the trackbar thumb is moved.
Thanks in advance.
Answers
- When the slider is moved with a mouse drag it sends WM_HSCROLL (or WM_VSCROLL) with nSBCode == TB_THUMBTRACK.
When the user releases the slider it sends the same scroll message with nSBCode == TB_THUMBPOSITION.- Marked As Answer bynobugzMVP, ModeratorFriday, July 03, 2009 2:32 PM
All Replies
- When the slider is moved with a mouse drag it sends WM_HSCROLL (or WM_VSCROLL) with nSBCode == TB_THUMBTRACK.
When the user releases the slider it sends the same scroll message with nSBCode == TB_THUMBPOSITION.- Marked As Answer bynobugzMVP, ModeratorFriday, July 03, 2009 2:32 PM
- I'm not sure why but I can never see those notifications occurring. I can see notifications such as NM_RELEASEDCAPTURE. Maybe I'm checking notifications on the wrong CWnd?
In case it is important, This slider is part of a dialog window which is a child window of a save dialog. - You are seeing WM_NOTIFY messages, but the control also sends WM_HSCROLL (or WM_VSCROLL) messages. Does your message handling intercept those messages?
- I have an OnNotify method that seems to intercept all of the WM_NOTIFY messages. I tried using an OnHScroll method but I still cannot get a TB_THUMBTRACK or TB_THUMBPOSITION message.
Show your code for OnHScroll. Is it called?
- Nothing is inside my OnHScroll function yet. I just have a variable assignment so that I can set a breakpoint to check if the function is called. It has not been called in my program but the OnNotify function continues to be called.
void CAlphaImgFileSave::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { int i = 0; } - I think I just figured out my problem. It was a very small and stupid mistake on my part. I forgot to add:
BEGIN_MESSAGE_MAP(CAlphaImgFileSave, CFileDialog) ON_WM_HSCROLL() END_MESSAGE_MAP()
- The OnHScroll must be in the control's parent window. Is your OnHScroll in the same class that receives the OnNotify? Does that class have ON_WM_HSCROLL() in its message map?
- Yes, it is in the same class as OnNotify. At first, it was not in the message map. I noticed that mistake and pointed it out above. It was a dumb mistake on my part but I think my problem is solved now.
Thanks!


