我正在尝试删除显示在 datetimepicker 控件底部的 Today 链接。我发现了一个与代码类似的问题,但这似乎不起作用 - 我的转换是否存在问题,或者这种方法不再有效(Visual Studio 2012)?
Class MyDateTimePicker
Inherits DateTimePicker
Protected Overrides Sub OnHandleCreated(e As EventArgs)
Dim style As Integer = CInt(SendMessage(Me.Handle, DTM_GETMCSTYLE, IntPtr.Zero, IntPtr.Zero))
style = style Or MCS_NOTODAY Or MCS_NOTODAYCIRCLE
SendMessage(Me.Handle, DTM_SETMCSTYLE, IntPtr.Zero, CType(0, IntPtr))
MyBase.OnHandleCreated(e)
End Sub
Private Const DTM_FIRST As Integer = &H1000
Private Const DTM_SETMCSTYLE As Integer = DTM_FIRST + 11
Private Const DTM_GETMCSTYLE As Integer = DTM_FIRST + 12
Private Const MCS_NOTODAYCIRCLE As Integer = &H8
Private Const MCS_NOTODAY As Integer = &H10
<DllImport("user32.dll")> _
Private Shared Function SendMessage(hWnd As IntPtr, msg As Integer, wp As IntPtr, lp As IntPtr) As IntPtr
End Function
End Class