Solved

CScrollBar Messages

Posted on 2000-04-03
7
341 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 30

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 30

Expert Comment

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

have a nice day,

ZOPPO
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Define unique primary key 9 81
haveThree challenge 22 100
How to convert MFC::CString to UTF8 wchar_t* 10 92
wordcount challenge 11 74
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 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

15 Experts available now in Live!

Get 1:1 Help Now