如何更改 TEdit 默认错误消息(NumbersOnly 模式)?
How can I change the TEdit's default error message when I use it in NumbersOnly mode. I mean this error:
Unacceptable character You can only type a number here
Is it possible to change this message ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道更改该消息的值(由 Windows 处理)的直接方法,但您可以使用
Abort
过程中的OnKeyPress
事件。检查此示例
您必须知道此代码将阻止在控件上执行剪贴板操作。
更新
I 更新代码以允许使用 Tab(#9) 和 Back space(#8) 字符。
I don't know a direct way to change the value of that message (which is handled by Windows) but you can show your own message and then avoid to show the original windows hint ballon, using the
Abort
procedure in theOnKeyPress
Event.Check this sample
You must we aware which this code will be prevent the execution of the clipboard operations over the control.
Update
I Update the code to allow the Tab(#9) and Back space(#8) chars.
查看 VCL 源代码,看起来该消息是由 Windows 生成的,而不是由 Delphi 生成的。也就是说,VCL 仅包装了 Windows 中存在的功能。所以看来修改这条消息并不容易。
Looking at the VCL source, it looks like that message is generated by windows, rather than by Delphi. That is, the VCL is only wrapping the functionality that exists in windows. So it doesn't appear that it would be easy to modify the message.