vendredi 13 mars 2015

VB.NET Textbox Cue Banner not setting - no error

(I've removed the old part as it's redundant)


EDIT -


Even without any knowledge of C#, I've tried to convert the code that Lars pointed me to... Managed to get it compiling. And useable from the toolbox. However, It doesn't seem like CueTextBox1.Cue = "Test" works. Again, no error seems to be produced. I've checked and the cue property has been added to properties for the CueTextBox, but changing it doesn't change the cue, or seemingly do anything for that matter. Here's the converted code:



Imports System
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Runtime.InteropServices

Class CueTextBox
Inherits TextBox
Public Property Cue() As String
Get
Return mCue
End Get
Set(value As String)
mCue = value
updateCue()
End Set
End Property

Private Sub updateCue()
If (Me.IsHandleCreated And mCue = Nothing) Then
SendMessage(Me.Handle, &H1501, New IntPtr(1), mCue)
End If
End Sub

Protected Overrides Sub OnHandleCreated(e As EventArgs)
MyBase.OnHandleCreated(e)
updateCue()
End Sub

Private mCue As String

<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wp As IntPtr, ByVal lp As String) As IntPtr
End Function
End Class


As Plutonix suggested, I have changed the last param of the PInvoke Sadly there was no change. Below is the updated block.



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

Aucun commentaire:

Enregistrer un commentaire