Changing the cursor in a Rich Edit View?

Hi,

I have a rich edit view in which I would like the cursor to become a standard arrow instead of an I-beam when the mouse is over it.  Since this is a rich edit control, I can not change the cursor definition in the class name, because the class name is automatically changed to the rich edit class name.  I have tried using SetLong to change it, but that only results in a flicker, like other solutions.  I have intercepted WM_SETCURSOR in CWnd::OnSetCursor() and changed it there, but that only works most of the time.  For example when the left mouse button is clicked and held and the mouse is dragged (when making a selection) the cursor changed back into an I-beam whenever it is over a part of the rich edit view that does not have text in it.  I am very puzzled by this and I haven't been able to find an answer anywhere else.  Please help.

- James
prodosAsked:
Who is Participating?
 
jtwine100697Connect With a Mentor Commented:
What you will need to do is register a copy of the RICHEDIT class, setting the hCursor member to the cursor that you want (IDC_ARROW), and then use that class for your control.  You will also have to handle OnSetCursor(), and set the cursor to the cursor that you want.

This prevents the cursor from changing back and forth.

I can provide you with code, if required.

-=- James.

0
 
chensuCommented:
Have you combined the two methods?
0
 
prodosAuthor Commented:
Yes I have, it seems when I combine them the arrow changes into the I-beam less frequently, but it still happens when making a selection.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
chensuCommented:
Show your code in OnSetCursor() please.
0
 
prodosAuthor Commented:
BOOL CIrcOutputView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
    if( nHitTest == HTCLIENT )
    {
        ::SetCursor( ArrowCursor );
        return TRUE;
    }
      
    return CRichEditView::OnSetCursor(pWnd, nHitTest, message);
}
0
 
chensuCommented:
What happens if you remove the "if( nHitTest == HTCLIENT )"?
0
 
prodosAuthor Commented:
It still changes back into an I-beam when making a selection, other than that it just makes it an arrow no matter where it is in the window (ie. it doesn't become the resize cursor when it is on the resizable frame).
0
 
prodosAuthor Commented:
Adjusted points to 200
0
 
prodosAuthor Commented:
Edited text of question
0
 
prodosAuthor Commented:
Adjusted points to 250
0
 
prodosAuthor Commented:
Great! How can I contact you directly, I have a couple minor questions about your answer.
0
 
jtwine100697Commented:
Hey...  Got your email..., going to reply...

-=- James.
0
 
jtwine100697Commented:
  You never replied to my Email...

   Did you receive it?

-=- James.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.