Article ID: 198880
Article Last Modified on 5/13/2003
Option Explicit
Private Sub Command1_Click()
' Set DTPicker MinDate through normal means.
Me.DTPicker1.MinDate = "1/10/99"
End Sub
Private Sub Command2_Click()
'Set DTPicker MaxDate through normal means.
Me.DTPicker1.MaxDate = "1/17/99"
End Sub
Private Sub Command3_Click()
Dim TimeArray(1) As SYSTEMTIME
Dim result As Long
' Define first element of SYSTEMTIME Array to be minimum date.
TimeArray(0).wDay = 10
TimeArray(0).wMonth = 1
TimeArray(0).wYear = 1999
' Call API to send message to control to set MinDate.
result = SendMessage(Me.DTPicker1.hwnd, DTM_SETRANGE, _
GDTR_MIN, TimeArray(0))
End Sub
Private Sub Command4_Click()
Dim TimeArray(1) As SYSTEMTIME
Dim result As Long
' Define second element of SYSTEMTIME Array to be maximum date.
TimeArray(1).wDay = 17
TimeArray(1).wMonth = 1
TimeArray(1).wYear = 1999
' Call API to send message to control to set MaxDate.
result = SendMessage(Me.DTPicker1.hwnd, DTM_SETRANGE, _
GDTR_MAX, TimeArray(0))
End Sub
Private Sub Command5_Click()
Dim TimeArray(1) As SYSTEMTIME
Dim result As Long
' Define first element of SYSTEMTIME Array to be minimum date.
TimeArray(0).wDay = 10
TimeArray(0).wMonth = 1
TimeArray(0).wYear = 1999
' Define second element of SYSTEMTIME Array to be maximum date.
TimeArray(1).wDay = 17
TimeArray(1).wMonth = 1
TimeArray(1).wYear = 1999
' Call API to send message to control to set MinDate and MaxDate.
result = SendMessage(Me.DTPicker1.hwnd, DTM_SETRANGE, _
GDTR_MIN + GDTR_MAX, TimeArray(0))
End Sub
Private Sub Form_Load()
Me.Command1.Caption = "Set DTPicker MinDate Normally"
Me.Command2.Caption = "Set DTPicker MaxDate Normally"
Me.Command3.Caption = "Set DTPicker MinDate Via API"
Me.Command4.Caption = "Set DTPicker MaxDate Via API"
Me.Command5.Caption = "Set DTPicker Min and MaxDate Via API"
End Sub
Option Explicit
Public Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type
Public Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long
Public Const DTM_SETRANGE = &H1004&
Public Const GDTR_MIN = 1
Public Const GDTR_MAX = 2
Additional query words: Minimum Maximum Range kbcode
Keywords: kbbug kbfix kbapi kbctrl kbvs600sp3fix KB198880