Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

CScrollBar Messages

Posted on 2000-04-03
7
Medium Priority
?
371 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 31

Accepted Solution

by:
Zoppo earned 400 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

618 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