Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how can I get the pointer of the scrollbar on the listctrl?

how can I get the pointer of the scrollbar on the listctrl?

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yingkou
    wrote on last edited by
    #1

    I want to handle the message that mouse click the vertical scrollbar of the listctrl,and codes as below: CMyListCtrl::public CListCtrl BOOL CMyListCtrl::PreTranslateMessage (MSG* pMsg) { CScrollBar* pScroll = GetScrollBarCtrl(SB_VERT);//pScroll is NULL!! if(NULL != pScroll && pMsg->hwnd == pScroll->GetSafeHwnd()){ BOOL flag = FALSE; CRect rect; pScroll->GetWindowRect(&rect); if (pMsg->message == WM_LBUTTONDOWN){ } }else if(pMsg->message == WM_LBUTTONUP){ } } }

    Y 1 Reply Last reply
    0
    • Y yingkou

      I want to handle the message that mouse click the vertical scrollbar of the listctrl,and codes as below: CMyListCtrl::public CListCtrl BOOL CMyListCtrl::PreTranslateMessage (MSG* pMsg) { CScrollBar* pScroll = GetScrollBarCtrl(SB_VERT);//pScroll is NULL!! if(NULL != pScroll && pMsg->hwnd == pScroll->GetSafeHwnd()){ BOOL flag = FALSE; CRect rect; pScroll->GetWindowRect(&rect); if (pMsg->message == WM_LBUTTONDOWN){ } }else if(pMsg->message == WM_LBUTTONUP){ } } }

      Y Offline
      Y Offline
      YaronNir
      wrote on last edited by
      #2

      Use a different approach check out the methods : CWnd::OnVScroll and CWnd::OnHScroll on MSDN , they will help you Yaron Ask not what your application can do for you, Ask what you can do for your application

      Y 1 Reply Last reply
      0
      • Y YaronNir

        Use a different approach check out the methods : CWnd::OnVScroll and CWnd::OnHScroll on MSDN , they will help you Yaron Ask not what your application can do for you, Ask what you can do for your application

        Y Offline
        Y Offline
        yingkou
        wrote on last edited by
        #3

        I just want to handle the message WM_LBUTTTONDOWN And WM_LBUTTONUP and not to handle the message of WM_VSCROLL

        J 1 Reply Last reply
        0
        • Y yingkou

          I just want to handle the message WM_LBUTTTONDOWN And WM_LBUTTONUP and not to handle the message of WM_VSCROLL

          J Offline
          J Offline
          Justin Tay
          wrote on last edited by
          #4

          There are 2 types of scrollbars, one that is a scrollbar control that has it's own window handle, and one that is drawn in the non-client area of a window. Most scrollbars are of the second type, drawn in the non-client area and not a window by itself. Handle WM_NCLBUTTONDOWN and WM_NCLBUTTONUP. You can check for the hittest value of HTVSCROLL to see if the vertical scrollbar has been clicked. Edit: Now that I think about it, what's wrong with YaronNir's solution? Do you have to do something on mouse down and then something on mouse up and not just checking for a click? -- modified at 7:32 Sunday 30th April, 2006

          Y 1 Reply Last reply
          0
          • J Justin Tay

            There are 2 types of scrollbars, one that is a scrollbar control that has it's own window handle, and one that is drawn in the non-client area of a window. Most scrollbars are of the second type, drawn in the non-client area and not a window by itself. Handle WM_NCLBUTTONDOWN and WM_NCLBUTTONUP. You can check for the hittest value of HTVSCROLL to see if the vertical scrollbar has been clicked. Edit: Now that I think about it, what's wrong with YaronNir's solution? Do you have to do something on mouse down and then something on mouse up and not just checking for a click? -- modified at 7:32 Sunday 30th April, 2006

            Y Offline
            Y Offline
            yingkou
            wrote on last edited by
            #5

            void CMyListCtrl::OnNcLButtonDown(UINT nHitTest, CPoint point) { // TODO: Add your message handler code here and/or call default if(HTVSCROLL == nHitTest) MessageBox("LButtonDown On Vertical Scroll");//Here is OK CListCtrl::OnNcLButtonDown(nHitTest, point); } void CMyListCtrl::OnNcLButtonUp(UINT nHitTest, CPoint point) { // TODO: Add your message handler code here and/or call default if(HTVSCROLL == nHitTest) MessageBox("LButtonUp On Vertical Scroll");//No MessageBox CListCtrl::OnNcLButtonUp(nHitTest, point); } how can I get the message of WM_LBUTTONUP of the Vertical Scroll Bar

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups