Solved

Capturing Vertical ScrollBar message from CRichEditCtrl Text Box

Posted on 2007-04-02
8
795 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
[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
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
unix example issues 18 114
how to use laptop or pad camera in vb.net windows application 2 133
Installshield for Embarcadero EX 10.1 Berlin 4 93
PL SQL Developer 7 90
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

710 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