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.