MSDN > Home page del forum > Visual C++ General > Trackbar Notifications
Formula una domandaFormula una domanda
 

Con rispostaTrackbar Notifications

  • giovedì 2 luglio 2009 21.34lesnaubrTSC Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     
    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.

Risposte

Tutte le risposte

  • venerdì 3 luglio 2009 3.10Scott McPhillipsMVPMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     Con risposta
    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.
  • lunedì 6 luglio 2009 13.20lesnaubrTSC Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     
    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.
  • lunedì 6 luglio 2009 13.57Scott McPhillipsMVPMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     
    You are seeing WM_NOTIFY messages, but the control also sends WM_HSCROLL (or WM_VSCROLL) messages.  Does your message handling intercept those messages?
  • lunedì 6 luglio 2009 14.30lesnaubrTSC Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     
    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.
  • lunedì 6 luglio 2009 15.13Scott McPhillipsMVPMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     

    Show your code for OnHScroll.  Is it called?

     

  • lunedì 6 luglio 2009 15.44lesnaubrTSC Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     Contiene codice
    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;
    }

  • lunedì 6 luglio 2009 16.21lesnaubrTSC Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     Contiene codice
    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()
  • lunedì 6 luglio 2009 16.28Scott McPhillipsMVPMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     
    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?

  • lunedì 6 luglio 2009 16.38lesnaubrTSC Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     
    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!