1

我尝试使用以下代码为 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

但是,文本没有设置。我该如何解决

4

1 回答 1

2

EM_SETCUEBANNER适用于TextBox控件。KryptonTextBox实际上是一个Control包含一个TextBox.

使用属性TextBox公开。TextBox您可以KryptonTextBox1.TextBox.Handle用来发送EM_SETCUEBANNER消息。

要查看组件的源代码,请查看此GitHub 存储库。这是代码的相关部分:

public class KryptonTextBox : VisualControlBase, IContainedInputControl
{
    //...
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
    [EditorBrowsable(EditorBrowsableState.Always)]
    [Browsable(false)]
    public TextBox TextBox
    {
        get { return _textBox; }
    }
    //...
}
于 2016-11-18T14:18:41.760 回答