Reputation: 5959
I tried using the following code to set cue banner for a kryptontextbox
Imports System.Runtime.InteropServices
Public Class Form1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
SetCueText(KryptonTextBox1.Handle, "Enter Name here")
End Sub
End Class
Public Module CueBannerText
<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
Private Function SendMessage(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As Integer, <MarshalAs(UnmanagedType.LPWStr)> ByVal lParam As String) As Int32
End Function
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As IntPtr, ByVal hWnd2 As IntPtr, ByVal lpsz1 As String, ByVal lpsz2 As String) As IntPtr
Private Const EM_SETCUEBANNER As Integer = &H1501
Public Sub SetCueText(hWnd As IntPtr, text As String)
if Not hWnd = IntPtr.Zero Then
SendMessage(hWnd, EM_SETCUEBANNER, 0, text)
End If
End Sub
End Module
however, the text is not getting set. how do i fix this
Upvotes: 1
Views: 140
Reputation: 125257
EM_SETCUEBANNER
is applicable on a TextBox
control. KryptonTextBox
in fact is a composite Control
which contains a TextBox
.
The TextBox
is exposed using a TextBox
property. You can use KryptonTextBox1.TextBox.Handle
to send EM_SETCUEBANNER
message.
To see the source code for components take a look at this GitHub repository. Here is a related part of code:
public class KryptonTextBox : VisualControlBase, IContainedInputControl
{
//...
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[EditorBrowsable(EditorBrowsableState.Always)]
[Browsable(false)]
public TextBox TextBox
{
get { return _textBox; }
}
//...
}
Upvotes: 2