自动换行上的火灾事件
有没有办法找出何时文本在 RichTextBox 中换行 (WordWrap)?我已经进行了相当多的挖掘,但到目前为止还没有找到任何东西,但我会继续寻找...
我正在研究这个的原因是因为每当 RichTextBox 将文本包装在末尾时我需要触发一个事件线。
谢谢大家
Is there some way to find out when the text gets wrapped (WordWrap) inside a RichTextBox? I've dug around quite a bit but haven't found anything so far, will keep looking though...
The reason I'm looking into this is because I need an event to fire whenever the RichTextBox wraps the text at the end of the line.
Thank you all
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从技术上讲,我相信使用 Windows API 可以实现这一点。查看 EM_SETHYPHENATEINFO 并在特别是传递自定义 HyphenateProc 的能力。这是一个指向函数的指针,当富文本框需要换行时调用该函数并调用您的函数来确定如何对单词进行连字符。
话虽如此,我真诚地怀疑这是否在 .NET 中公开,因此您需要进一步深入研究 API。但我认为这将是在每次换行时收到通知的最佳方式。
更新
在这里,我找到了一个博客帖子 更详细地讨论了这一点。
Technically I believe this is possible with the Windows API. Take a look at EM_SETHYPHENATEINFO and in particular, the ability to pass a custom HyphenateProc. This is a pointer to a function that is called when the rich text box needs to wrap a line and calls your function to determine how to hyphenate the word.
Having said that, I sincerely doubt this is exposed in .NET so you would need to dig into the API a bit more. But I think this would be the best way of being notified on each line wrap.
UPDATE
Here you go I found a blog post that talks about this in a bit more detail.