mirror of
https://github.com/zhaopeiym/IoTClient
synced 2025-10-26 22:15:44 +08:00
25 lines
691 B
C#
25 lines
691 B
C#
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
|
|
namespace IoTClient.Tool.Controls
|
|
{
|
|
public class TextBoxEx : TextBox
|
|
{
|
|
public string PlaceHolder { get; set; }
|
|
protected override void WndProc(ref Message m)
|
|
{
|
|
base.WndProc(ref m);
|
|
if (m.Msg == 0xF || m.Msg == 0x133)
|
|
{
|
|
WmPaint(ref m);
|
|
}
|
|
}
|
|
private void WmPaint(ref Message m)
|
|
{
|
|
Graphics g = Graphics.FromHwnd(Handle);
|
|
if (!string.IsNullOrEmpty(PlaceHolder) && string.IsNullOrEmpty(Text))
|
|
g.DrawString(PlaceHolder, Font, new SolidBrush(Color.LightGray), 2, 2);
|
|
}
|
|
}
|
|
}
|