TextBox的文本被选择时的消息

有鱼雅雅 2019-07-27 03:38:23
请问TextBox的文本在被选择时应该截获什么消息进行处理?我想知道用户在选择文本时的动作,无论是键盘动作还是鼠标动作。类似JavaScript的onselect 或 onselectstart 这样的WM_消息。
...全文
176 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
milaoshu1020 2019-07-27
  • 打赏
  • 举报
回复
EM_GETSEL message
2018/05/31
2 分钟阅读时长

Gets the starting and ending character positions (in TCHARs) of the current selection in an edit control. You can send this message to either an edit control or a rich edit control.

Parameters
wParam

A pointer to a DWORD value that receives the starting position of the selection. This parameter can be NULL.

lParam

A pointer to a DWORD value that receives the position of the first unselected character after the end of the selection. This parameter can be NULL.

Return value
The return value is a zero-based value with the starting position of the selection in the LOWORD and the position of the first TCHAR after the last selected TCHAR in the HIWORD. If either of these values exceeds 65,535, the return value is -1.

It is better to use the values returned in wParam and lParam because they are full 32-bit values.

Remarks
If there is no selection, the starting and ending values are both the position of the caret.

Rich edit controls: You can also use the EM_EXGETSEL message to retrieve the same information. EM_EXGETSEL also returns starting and ending character positions as 32-bit values.

Rich Edit: Supported in Microsoft Rich Edit 1.0 and later. For information about the compatibility of rich edit versions with the various system versions, see About Rich Edit Controls.

Requirements
Minimum supported client
Windows Vista [desktop apps only]
Minimum supported server
Windows Server 2003 [desktop apps only]
Header
Winuser.h (include Windows.h)
See also
Reference

EM_EXGETSEL

EM_SETSEL
milaoshu1020 2019-07-27
  • 打赏
  • 举报
回复
EM_GETSEL;

1,488

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧