Solved

Capturing Vertical ScrollBar message from CRichEditCtrl Text Box

Posted on 2007-04-02
8
736 Views
Last Modified: 2013-11-25
I'm trying to enable a "RadioButton" on a License Agreement look-a-like dialog when the user scrolls down on the License Agreement Richedit TextBox, developed in MFC(VC++ 6.0).
I'm not able to capture any of the WM_VSCROLL message from the scroll bar.

Can anyone throw some light on the problem?
0
Comment
Question by:Leo01
  • 4
  • 3
8 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 18837155
Where have you put your 'OnVScroll()' handler? Is it part of the rich edit control or the dialog?
0
 

Author Comment

by:Leo01
ID: 18837226
Part of the Dialog. In fact I have tried to capture from the richedit control too but no success.
I tried to step into these function while I scroll the "text",without success.
Here is my MEssageMap...
BEGIN_MESSAGE_MAP(CLicenseAgreementDlg, CDialog)
      //{{AFX_MSG_MAP(CLicenseAgreementDlg)
      ON_WM_PAINT()
      ON_WM_QUERYDRAGICON()
      ON_BN_CLICKED(IDC_RADIO2      , OnRadio2)
      ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
      ON_NOTIFY(NM_CLICK, IDC_RICHEDIT3, OnChangeLicenseText)
      ON_BN_CLICKED(IDC_PRINT, OnPrint)
      ON_BN_CLICKED(IDOK, OnSelectNext)
      ON_NOTIFY(EN_SETFOCUS, IDC_RICHEDIT3, OnSetfocusRichedit3)
      ON_EN_UPDATE(IDC_RICHEDIT3, OnUpdateRichedit3)
      ON_NOTIFY(EN_SELCHANGE, IDC_RICHEDIT3, OnSelchangeRichedit3)
      ON_NOTIFY(EN_KILLFOCUS, IDC_RICHEDIT3, OnKillfocusRichedit3)
      ON_EN_CHANGE(IDC_RICHEDIT3, OnChangeRichedit3)
      ON_WM_VSCROLL()
      ON_WM_CANCELMODE()
      ON_EN_VSCROLL(IDC_RICHEDIT3, OnVscrollRichedit3)
      ON_NOTIFY(NM_DBLCLK, IDC_RICHEDIT3, OnDblclkRichedit3)
      ON_NOTIFY(NM_RCLICK, IDC_RICHEDIT3, OnRclickRichedit3)
      ON_NOTIFY(NM_RETURN, IDC_RICHEDIT3, OnReturnRichedit3)
      ON_NOTIFY(NM_SETFOCUS, IDC_RICHEDIT3, OnSetfocusRichedit3)
      ON_NOTIFY(NM_KILLFOCUS, IDC_RICHEDIT3, OnKillfocusRichedit3)
      ON_WM_MOUSEMOVE()
      ON_WM_SETFOCUS()
      ON_WM_KEYDOWN()
      ON_WM_KEYUP()
      //}}AFX_MSG_MAP
END_MESSAGE_MAP()
0
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 18837431
Unfortunately it isn't easy to get scroll bar events for a CDialog. It would have been easier for a CFormView where the appropriate scroll events are available via the baseclass.

For a CDialog you you only have a standard scrollbar. You might catch scroll events by overloading CYourDialog::PreTranslateMessage and check for WM_VSCROLL messages.

Another way is to not make the dialog form have a standard scroll bar but create a CScrollbar control instead. You could overlaod it by an own class and have to subclass it to get scroll messages directly passed via message map. But it is a lot of work and maybe only last resort ...

Regards, Alex
 
0
 

Author Comment

by:Leo01
ID: 18838193
Thanks for your input Alex!
Can you provide an example or point me to one for either options?
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 18839293
define prototype in your dialog class:

virtual BOOL PreTranslateMessage(
   MSG* pMsg
);


Implement it like

BOOL MyDialog::PreTranslateMessage(MSG* pMsg)
{
      if (pMsg->message == WM_VSCROLL)
      {
           
      }
      return FALSE;   // not handled completely
}

The scroll event is coded in pMsg->wParam:

Parameters
wParam
The low-order word specifies a scroll bar value that indicates the user's scrolling request. This parameter can be one of the following values. Value Meaning
SB_BOTTOM Scrolls to the lower right.
SB_ENDSCROLL Ends scroll.
SB_LINEDOWN Scrolls one line down.
SB_LINEUP Scrolls one line up.
SB_PAGEDOWN Scrolls one page down.
SB_PAGEUP Scrolls one page up.
SB_THUMBPOSITION The user has dragged the scroll box (thumb) and released the mouse button. The high-order word indicates the position of the scroll box at the end of the drag operation.
SB_THUMBTRACK The user is dragging the scroll box. This message is sent repeatedly until the user releases the mouse button. The high-order word indicates the position that the scroll box has been dragged to.
SB_TOP Scrolls to the upper left.


The high-order word specifies the current position of the scroll box if the low-order word is SB_THUMBPOSITION or SB_THUMBTRACK; otherwise, this word is not used.

Regards, Alex

P.S.
You also could do (alternatively) CTRL + W class wizard. Choose dialog class. Change message filter to CWnd (window). Choose message WM_VSCROLL and add handler.


0
 

Author Comment

by:Leo01
ID: 18840166
Thanks for your suggestions.
I don't see the WM_VSCROLL messages in the 'PreTranslateMessage'. Looks like, I may have to try your other alternative.
While I'm working on your option 1.  I got a dirty idea of checking the scrollbarInfo in the 'Pretranslatemessage' and it works. I know it's not good, but atleast I have a solution now.

This is just one-off dialog and there are no predecessors or successors to this dialog that I need to worry about;More over user will see this dialog once in the life-time of the product for a few seconds, so it's not that dirty after-all.

I will allot your well deserved points as soon as I try your second option.(Irrespective of the result :)) )

Thanks again!
0
 
LVL 39

Accepted Solution

by:
itsmeandnobodyelse earned 500 total points
ID: 18841445
>>>> I know it's not good, but atleast I have a solution now.

Not so bad, though PreTranslateMessage was called very often. Maybe you should check the scrollbarInfo only any 10th message. Your dialog has no extra scrollbar but a standard scrollbar? A standard scrollbar occurs automatically if the form doesn't fit to the screen while a non-standard scrollbar is a separate control. Following the docs you only get WM_VSCROLL messages if you have a standard scrollbar (otherwise the control gets the messages).

Regards, Alex
0
 

Author Comment

by:Leo01
ID: 18843412
I have a standard scroll bar.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

708 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

13 Experts available now in Live!

Get 1:1 Help Now