MSDN > 論壇首頁 > Visual C++ General > Trackbar Notifications
發問發問
 

已答覆Trackbar Notifications

  • 2009年7月2日 下午 09:34lesnaubrTSC 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    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.

解答

  • 2009年7月3日 上午 03:10Scott McPhillipsMVP使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     已答覆
    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.

所有回覆

  • 2009年7月3日 上午 03:10Scott McPhillipsMVP使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     已答覆
    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.
  • 2009年7月6日 下午 01:20lesnaubrTSC 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    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.
  • 2009年7月6日 下午 01:57Scott McPhillipsMVP使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    You are seeing WM_NOTIFY messages, but the control also sends WM_HSCROLL (or WM_VSCROLL) messages.  Does your message handling intercept those messages?
  • 2009年7月6日 下午 02:30lesnaubrTSC 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    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.
  • 2009年7月6日 下午 03:13Scott McPhillipsMVP使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     

    Show your code for OnHScroll.  Is it called?

     

  • 2009年7月6日 下午 03:44lesnaubrTSC 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     包含代碼
    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;
    }

  • 2009年7月6日 下午 04:21lesnaubrTSC 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     包含代碼
    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()
  • 2009年7月6日 下午 04:28Scott McPhillipsMVP使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    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?

  • 2009年7月6日 下午 04:38lesnaubrTSC 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    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!