gpt4 book ai didi

c++ - 在 RichEdit winapi 中隐藏插入符号

转载 作者:太空宇宙 更新时间:2023-11-04 13:27:23 25 4
gpt4 key购买 nike

我想在指定了 ES_READONLY 样式的 RichEdit(50W) 中隐藏插入符号。当插入符闪烁且用户无法输入时,这对用户来说非常困惑。
我试图使用 HideCaret() 隐藏插入符号功能,
但是它不适用于以下代码:

LRESULT CALLBACK ChatMessaegsSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) // Subclassed control
{
LRESULT ret = CallWindowProc(WndProc_ChatMessages, hwnd, msg, wParam, lParam);
switch(msg)
{
//Also tried with EN_SETFOCUS
case WM_SETFOCUS:
{
ret = CallWindowProc(WndProc_ChatMessages, hwnd, msg, wParam, lParam);
HideCaret(ChatMessages); //Returns 5 (Access denied.)
break;
}

//According the documentation:
//If your application calls HideCaret five times in a row,
//it must also call ShowCaret five times before the caret is displayed.
case WM_KILLFOCUS: //The message is called when the RichEdit get focus, however nothing happens.
{
ret = CallWindowProc(WndProc_ChatMessages, hwnd, msg, wParam, lParam);
ShowCaret(ChatMessages);
break;
}
}
return ret;
}

最佳答案

解决方法如下:

LRESULT CALLBACK ChatMessaegsSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
LRESULT ret = CallWindowProc(WndProc_ChatMessages, hwnd, msg, wParam, lParam);
switch(msg)
{
case WM_LBUTTONDOWN:
{
HideCaret(ChatMessages);
break;
}
case WM_KILLFOCUS:
{
ShowCaret(ChatMessages);
break;
}
}
return ret;
}

注意 这仅在用户使用鼠标引导焦点时有效。因此,如果有人知道如何正确处理它,请随时回答,我会很高兴。

关于c++ - 在 RichEdit winapi 中隐藏插入符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32896767/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com