绘制了在.NET Compact Framework的一个TextBox [英] Drawing over a TextBox in .NET Compact Framework

查看:121
本文介绍了绘制了在.NET Compact Framework的一个TextBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能绘制过的.NET Compact Framework的一个TextBox控件?我想创建一个水印权。我已阅读这个答案。这是我目前最好的办法,但我不想限制自己显示水印,只有当文本框没有焦点。

Is it possible to draw over a TextBox control in .NET Compact Framework? I want to create a watermark over it. I have read this answer. It's currently my best approach, but I do not want to limit myself to displaying the watermark only when the TextBox does not have the focus.

我愿意尝试任何黑客!

推荐答案

如果我要做到这一点,我想创建一个派生自文本框控件,这样你得到所有的基础渲染,事件,文本和选择,亚达,亚达。我则P / Invoke来的SetWindowLong改变窗口处理程序,并在自定义处理程序处理WM_PAINT,在水印或任何你想要的绘制。

If I were to do this, I'd create a control that derives from TextBox, that way you get all of the base rendering, events, text and selection, yada-yada. I'd then P/Invoke to SetWindowLong to change the window handler, and handle WM_PAINT in a custom handler, drawing in the watermark or whatever you want.

有一个良好的基础的例子就是 OpenNETCF.Windows.Forms.TextBox2 类,这是否子类化到处理剪切/复制/粘贴操作。我相信,code自1.x的天一直存在,因此code是免费提供的(在上面的链接页面底部)如果你没有/想要最新的。

A good base example is the OpenNETCF.Windows.Forms.TextBox2 class that does this subclassing to handle cut/copy/paste operations. I believe that code has been there since the 1.x days, so the code is freely available (bottom of the page in the link above) if you don't have/want the latest.

这篇关于绘制了在.NET Compact Framework的一个TextBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆