MFC Richedit hide cursor

Source: Internet
Author: User
MFC Richedit hide cursor

1. Reload the Richedit LButton event
Void CChatRichEd: OnLButtonDown (UINT nFlags, CPoint point)
{
CRichEditCtrl: OnLButtonDown (nFlags, point );
HideCaret ();
}
2. If there is a webpage link at the end of EN_Link
HideCaret ();

Change Richedit's editable mouse status by default
The OnSetCursor and m_isLink are used to determine whether it is a link,

BOOL CChatRichEd: OnSetCursor (CWnd * pWnd, UINT nHitTest, UINT message)
{
// TODO: add the message processing program code and/or call the default value here

// Return CRichEditCtrl: OnSetCursor (pWnd, nHitTest, message );
If (m_isLink)
{
M_isLink = FALSE;
Return CRichEditCtrl: OnSetCursor (pWnd, nHitTest, message );
}
Else
{
SetCursor (AfxGetApp ()-> LoadStandardCursor (IDC_ARROW ));
Return true;
}
}

EN_Link event
M_isLink = true.

In this way, the link is displayed as a hand.

 

Other methods on the Internet to hide Caret

1. Add the following global variables and functions after the MESSAGE_MAP declaration in the cpp file:

WNDPROC oldProc;

Lresult callback ReditWindowProc (
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
Switch (uMsg)
{
Case WM_SETFOCUS:
Return 0;

Default: NULL;
}
Return oldProc (hwnd, uMsg, wParam, lParam );
}

Call in OnInitDialog:

// TODO: Add extra initialization here

OldProc = (WNDPROC): SetWindowLong
(M_richEdit.m_hWnd, GWL_WNDPROC, (LONG) ReditWindowProc );

In this way, you can hide caret :)

 

2. comment out the methods in OnSetFocus.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.