Solved

CScrollBar Messages

Posted on 2000-04-03
7
356 Views
Last Modified: 2013-11-20
I am trying to process a on LBUTTONUP message for a scroll bar. But it doesn't seem to be getting one. I can see from the spy tool that one is being sent, but my scroll bar class is not picking it up. Can anyone tell me where this message is going and how to process it?
0
Comment
Question by:wrobel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 4

Expert Comment

by:captainkirk
ID: 2680502
Try deriving your own scroll bar class and overriding PreTranslateMessage() to catch it there.
0
 
LVL 1

Expert Comment

by:mahno
ID: 2680710
Hi wrobel,

U can add to dialog function:
void CTESTDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
  if (nSBCode == SB_ENDSCROLL) {
    //This message such as WM_LBUTTONUP
    //Add your code here...
  }

  CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
}

Or U can use captainkirk, method

Hope that helps,
  mahno
0
 

Author Comment

by:wrobel
ID: 2683197
I'm sure what you were trying to tell me. I need to find out if the left mouse button is up or not. I did what captainkirk said but the message doesn't even get there. It seem to be lost when my program runs through some RTL2( a really old language) code, which is called in my scroll down code.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 31

Accepted Solution

by:
Zoppo earned 100 total points
ID: 2683475
Hi wrobel,

only way I found is via MouseHook, i.e.:


// In .h file
class CMyScroll : public CScrollBar
{
 ...
 static HHOOK sbHook;
 static HWND sbHandle;

 static LRESULT CALLBACK MouseHook(int nCode, WPARAM wParam, LPARAM lParam);
 ...
};

// In .cpp file
HHOOK CMyScroll::sbHook = NULL;
HWND CMyScroll::sbHandle = NULL;

LRESULT CALLBACK CMyScroll::MouseHook(int nCode, WPARAM wParam, LPARAM lParam)
{
 MOUSEHOOKSTRUCT *mh = (MOUSEHOOKSTRUCT *)lParam;
 if ( mh->hwnd == sbHandle && wParam == WM_LBUTTONUP )
 {
  ::PostMessage( sbHandle, WM_LBUTTONUP, MAKELPARAM( mh->pt.x, mh->pt.y ), 0 );
 }
 return  CallNextHookEx( sbHook, nCode, wParam, lParam );
}

void CMyScroll::OnLButtonDown(UINT nFlags, CPoint point)
{
 m_bDown = TRUE;
 sbHandle = m_hWnd;
 sbHook = SetWindowsHookEx( WH_MOUSE, MouseHook, NULL, AfxGetThread()->m_nThreadID );
 CScrollBar::OnLButtonDown(nFlags, point);
}

void CMyScroll::OnLButtonUp(UINT nFlags, CPoint point)
{
 if( NULL != sbHook )
 {
  UnhookWindowsHookEx( sbHook );
  sbHook = NULL;
 }
 AfxMessageBox( "Left Button Up!" );
 CScrollBar::OnLButtonUp(nFlags, point);
}

hope that helps,

ZOPPO
0
 

Author Comment

by:wrobel
ID: 2689089
Adjusted points from 50 to 100
0
 

Author Comment

by:wrobel
ID: 2689090
Excellent that worked a treat, thank you very much for you answer.
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 2689093
I'm glad I could help you,

have a nice day,

ZOPPO
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question