mirror of
https://github.com/Orbmu2k/nvidiaProfileInspector.git
synced 2025-12-23 23:18:07 -05:00
35 lines
1.1 KiB
C#
35 lines
1.1 KiB
C#
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
|
|
namespace nspector
|
|
{
|
|
public class WatermarkTextBox : TextBox
|
|
{
|
|
private const int WM_PAINT = 0x000F;
|
|
|
|
private string _watermarkText;
|
|
[Category("Appearance")]
|
|
public string WatermarkText
|
|
{
|
|
get => _watermarkText;
|
|
set { _watermarkText = value; Invalidate(); }
|
|
}
|
|
|
|
protected override void WndProc(ref Message m)
|
|
{
|
|
base.WndProc(ref m);
|
|
|
|
if (m.Msg == WM_PAINT && string.IsNullOrEmpty(this.Text) && !string.IsNullOrEmpty(_watermarkText))
|
|
{
|
|
using (Graphics g = this.CreateGraphics())
|
|
using (Brush brush = new SolidBrush(SystemColors.GrayText))
|
|
{
|
|
TextFormatFlags flags = TextFormatFlags.VerticalCenter | TextFormatFlags.Left;
|
|
TextRenderer.DrawText(g, _watermarkText, this.Font, this.ClientRectangle, SystemColors.GrayText, flags);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|