Solved

Capturing Vertical ScrollBar message from CRichEditCtrl Text Box

Posted on 2007-04-02
8
747 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
child constructor and parent constructor, overriding and overloading 6 77
EvenOdd challenge 10 88
C++ mouse_event mouse look 7 68
What is sub-make ? 2 38
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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…

919 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

18 Experts available now in Live!

Get 1:1 Help Now