|
-
Jan 23rd, 2002, 12:09 PM
#1
Thread Starter
New Member
DateTimePicker
Hi all.. I'm trying to set the date on a datetime picker on a non-Automation App.. I'm able to get the hwnd but i'm not able to change the date.. here is the function i'm using
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 Function ChangeDate(ByVal lWinHandle As Long)
Dim lRtn As Long
Dim SysTime As SYSTEMTIME
Dim dtmDate As Date
dtmDate = Now()
With SysTime
.wYear = Year(dtmDate)
.wMonth = Month(dtmDate)
.wDay = Day(dtmDate)
End With
lRtn = SendMessage(lWinHandle, DTM_SETSYSTEMTIME, 0, SysTime)
ChangeDate = lRtn
End Function
With spy++ I can see where I send the DTM_SETSYSTEMTIME but nothing happens I always get a return value of 0. Does anyone have any ideas
Thanks
Tim
-
Jan 23rd, 2002, 12:29 PM
#2
Try this
VB Code:
Private 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
Private Declare Function SetSystemTime Lib "kernel32" _
(lpSystemTime As SYSTEMTIME) As Long
Private Const WM_TIMECHANGE = &H1E
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Any) As Long
Private Const HWND_TOPMOST = -1
Private Sub Command1_Click()
Dim dwret As Long
Dim st As SYSTEMTIME
With st
.wYear = 1999
.wMonth = 9
.wDay = 1
.wHour = 16
.wMinute = 0
.wSecond = 0
.wMilliseconds = 0
End With
dwret = SetSystemTime(st)
If dwret = 1 Then
'
' This updates the Windows displaying the system time
'
Call SendMessage(HWND_TOPMOST, WM_TIMECHANGE, 0, 0)
End If
End Sub
-
Jan 23rd, 2002, 01:07 PM
#3
Thread Starter
New Member
Thank you but it still does not chage the date on the datetimepicker.. it does change the system time, but i'm not trying to do that.
the class name for the datetimepicker is SysDateTimePick32 it is a child window on a Dialog Class.
Thank you
-
Jan 23rd, 2002, 03:00 PM
#4
Thread Starter
New Member
Thank you but it still does not chage the date on the datetimepicker.. it does change the system time, but i'm not trying to do that.
the class name for the datetimepicker is SysDateTimePick32 it is a child window on a Dialog Class.
Thank you
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|