Solved

Capturing Vertical ScrollBar message from CRichEditCtrl Text Box

Posted on 2007-04-02
8
761 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to convert MFC::CString to UTF8 wchar_t* 10 205
Annoying "thing" blocks my view 4 100
windbg taking it's time 32 90
C++ :Change value from  DisableCMD registry 4 59
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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 viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

776 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