I want to show standard "pointer" cursor instead of "text-selection cursor" (shown in the picture below) in RichEdit:
The only way I see now is to intercept WM_SETCURSOR
message in my window, determine wether cursor is inside RichEdit control, and replace it with "normal" cursor. Besides it's not so cool, I want to keep a "hand" cursor, which appears when cursor points to a link.
Is there an easier method?
UPDATE: Some clarifications for comments:
ES_READONLY
property, it does not affect neither cursor, nor selection (the latter I solved by intercepting the EN_SELCHANGE
notifications). // This method processes the WM_SETCURSOR message.
LRESULT MainWindow::OnSetCursor(WPARAM wParam, LPARAM lParam) {
auto h = (HWND)wParam;
if (h == richEditHwnd) {
return TRUE; // Prevents cursor changes by next processors
}
return DefWindowProc(mainWindowHandle, WM_SETCURSOR, wParam, lParam);
}
To change the cursor to arrow, use ES_READONLY
style, and handle WM_SETCURSOR
.
SetCursor(hcursor)
must be called each time:
hcursor = LoadCursor(nullptr, MAKEINTRESOURCE(IDC_ARROW));
...
case WM_SETCURSOR:
{
if (hrichedit == (HWND)wparam) { SetCursor(hcursor); return TRUE; }
break;
}
You are likely handling hyperlinks in WM_NOTIFY
, you can change hcursor
when cursor is over hyperlink.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.