0
我發現代碼Watermark TextBox in WinForms但它是C#的版本,所以我用http://converter.telerik.com/的代碼到VB版本轉換,但我仍然得到錯誤......如何創建水印文本框?
錯誤發生在這條線: -
的SendMessage(Me.Handle,& H1501,DirectCast(1,IntPtr的),mCue)
我怎樣才能解決這個問題?
錯誤消息:BC30311'Integer'類型的值無法轉換爲'IntPtr'。
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Class CueTextBox
Inherits TextBox
<Localizable(True)> _
Public Property Cue() As String
Get
Return mCue
End Get
Set
mCue = value
updateCue()
End Set
End Property
Private Sub updateCue()
If Me.IsHandleCreated AndAlso mCue IsNot Nothing Then
SendMessage(Me.Handle, &H1501, DirectCast(1, IntPtr), mCue) 'this line get the error msg
End If
End Sub
Protected Overrides Sub OnHandleCreated(e As EventArgs)
MyBase.OnHandleCreated(e)
updateCue()
End Sub
Private mCue As String
' PInvoke
<DllImport("user32.dll", CharSet := CharSet.Unicode)> _
Private Shared Function SendMessage(hWnd As IntPtr, msg As Integer, wp As IntPtr, lp As String) As IntPtr
End Function
End Class
謝謝,問題解決了 – vbnewbie