Solved

CScrollBar Messages

Posted on 2000-04-03
7
343 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
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
iSeries FTP Exit Program 8 124
Modbus - whats the maximum I can store in one register? 4 78
Can not remove SSL certificate on iPhone 6 - iOS10.2 12 284
Problem to open Excel file 15 99
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

867 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now