Solved

Changing the cursor in a Rich Edit View?

Posted on 1998-02-09
13
484 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
  • 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Decoding 32 bit binary streams 6 49
iSeries FTP Exit Program 8 146
Expand data scrubbing tool 13 35
Bartender label printing - switch on and off graphics 3 54
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

856 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