Solved

CScrollBar Messages

Posted on 2000-04-03
7
348 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

821 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