how can I get the pointer of the scrollbar on the listctrl?
-
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){ } } }
-
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){ } } }
-
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
-
I just want to handle the message WM_LBUTTTONDOWN And WM_LBUTTONUP and not to handle the message of WM_VSCROLL
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
-
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
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