Solved

Changing the cursor in a Rich Edit View?

Posted on 1998-02-09
13
487 Views
Last Modified: 2013-11-19
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
0
Comment
Question by:prodos
[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
  • 7
  • 3
  • 3
13 Comments
 
LVL 23

Expert Comment

by:chensu
ID: 1315854
Have you combined the two methods?
0
 

Author Comment

by:prodos
ID: 1315855
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
 
LVL 23

Expert Comment

by:chensu
ID: 1315856
Show your code in OnSetCursor() please.
0
Industry Leaders: 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:prodos
ID: 1315857
BOOL CIrcOutputView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
    if( nHitTest == HTCLIENT )
    {
        ::SetCursor( ArrowCursor );
        return TRUE;
    }
      
    return CRichEditView::OnSetCursor(pWnd, nHitTest, message);
}
0
 
LVL 23

Expert Comment

by:chensu
ID: 1315858
What happens if you remove the "if( nHitTest == HTCLIENT )"?
0
 

Author Comment

by:prodos
ID: 1315859
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
 

Author Comment

by:prodos
ID: 1315860
Adjusted points to 200
0
 

Author Comment

by:prodos
ID: 1315861
Edited text of question
0
 
LVL 4

Accepted Solution

by:
jtwine100697 earned 250 total points
ID: 1315862
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
 

Author Comment

by:prodos
ID: 1315863
Adjusted points to 250
0
 

Author Comment

by:prodos
ID: 1315864
Great! How can I contact you directly, I have a couple minor questions about your answer.
0
 
LVL 4

Expert Comment

by:jtwine100697
ID: 1315865
Hey...  Got your email..., going to reply...

-=- James.
0
 
LVL 4

Expert Comment

by:jtwine100697
ID: 1315866
  You never replied to my Email...

   Did you receive it?

-=- James.
0

Featured Post

Industry Leaders: 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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

707 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