TextBox watermark (CueBanner) which goes away when user types in single line TextBox (not for RichTextBox).

  • Thread starter Thread starter Mr. Monkeyboy
  • Start date Start date
M

Mr. Monkeyboy

Guest
Just for info if anyone interested. Maybe code is already in this Forum but I've not seen it before.

Pic2 without TextBox2 password char set, Pic3 with TextBox2 password char set.

EM_SETCUEBANNER message


Option Strict On

Imports System.Runtime.InteropServices

Public Class Form1

<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
Private Shared Function SendMessage(hWnd As IntPtr, msg As Integer, wParam As Integer, <MarshalAs(UnmanagedType.LPWStr)> lParam As String) As Int32
End Function

Const EM_SETCUEBANNER As Integer = &H1501

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Location = New Point(CInt((Screen.PrimaryScreen.WorkingArea.Width / 2) - (Me.Width / 2)), CInt((Screen.PrimaryScreen.WorkingArea.Height / 2) - (Me.Height / 2)))
'TextBox2.PasswordChar = CChar("*")
SendMessage(TextBox1.Handle, EM_SETCUEBANNER, 1, "Username")
SendMessage(TextBox2.Handle, EM_SETCUEBANNER, 1, "Password")
End Sub

End Class



902998.png


La vida loca

Continue reading...
 
Back
Top