-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWatermarkTextBox.cs
More file actions
42 lines (37 loc) · 1.1 KB
/
WatermarkTextBox.cs
File metadata and controls
42 lines (37 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace Exps
{
public partial class WatermarkTextBox : TextBox
{
public WatermarkTextBox()
{
InitializeComponent();
}
private const uint ECM_FIRST = 0x1500;
private const uint EM_SETCUEBANNER = ECM_FIRST + 1;
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, uint wParam, [MarshalAs(UnmanagedType.LPWStr)] string lParam);
private string watermarkText;
public string WatermarkText
{
get { return watermarkText; }
set
{
watermarkText = value;
SetWatermark(watermarkText);
}
}
private void SetWatermark(string watermarkText)
{
SendMessage(this.Handle, EM_SETCUEBANNER, 0, watermarkText);
}
}
}