Monday, August 06, 2007

MFC Slider Control Message Handling

I worked with horizontal slider control in MFC.

in order to receive the slider control messages,
 
 we have to add the HSCROLL or VSCROLL message

I added the following message :

ON_WM_HSCROLL() added it within BEGIN_MESSAGE () macro.

next I added the fn like

afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) ;

while using Slider control, the SCROLL message is posted...

There are two main notification codes are available.

That are

          TB_THUMBTRACK

//Slider movement (the user dragged the slider)

          TB_THUMBPOSITION

//WM_LBUTTONUP following a TB_THUMBTRACK notification message

 

void MFCDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)

{

       CSliderCtrl * pControl = (CSliderCtrl*) pScrollBar);

        switch(nSBCode)

         {

             case TB_THUMBTRACK://Slider movement (the user dragged the slider)

              {

                break;

             }

               case TB_THUMBPOSITION:

                 {

                     //WM_LBUTTONUP following a TB_THUMBTRACK notification message

                      //StopTimer();

                        break;

                  }

         }

}

0 Comments:

Post a Comment

<< Home