Capturing Vertical ScrollBar message from CRichEditCtrl Text Box

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?
Leo01Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jkrCommented:
Where have you put your 'OnVScroll()' handler? Is it part of the rich edit control or the dialog?
0
Leo01Author Commented:
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
itsmeandnobodyelseCommented:
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
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

Leo01Author Commented:
Thanks for your input Alex!
Can you provide an example or point me to one for either options?
0
itsmeandnobodyelseCommented:
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
Leo01Author Commented:
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
itsmeandnobodyelseCommented:
>>>> 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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Leo01Author Commented:
I have a standard scroll bar.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.