Results 1 to 4 of 4

Thread: DateTimePicker

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2002
    Location
    Memphis , TN
    Posts
    4

    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

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Try this
    VB Code:
    1. Private Type SYSTEMTIME
    2.     wYear As Integer
    3.     wMonth As Integer
    4.     wDayOfWeek As Integer
    5.     wDay As Integer
    6.     wHour As Integer
    7.     wMinute As Integer
    8.     wSecond As Integer
    9.     wMilliseconds As Integer
    10. End Type
    11.  
    12. Private Declare Function SetSystemTime Lib "kernel32" _
    13.     (lpSystemTime As SYSTEMTIME) As Long
    14. Private Const WM_TIMECHANGE = &H1E
    15.  
    16. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
    17.     (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
    18.     lParam As Any) As Long
    19.  
    20. Private Const HWND_TOPMOST = -1
    21.  
    22. Private Sub Command1_Click()
    23.     Dim dwret As Long
    24.     Dim st As SYSTEMTIME
    25.  
    26.     With st
    27.         .wYear = 1999
    28.         .wMonth = 9
    29.         .wDay = 1
    30.         .wHour = 16
    31.         .wMinute = 0
    32.         .wSecond = 0
    33.         .wMilliseconds = 0
    34.     End With
    35.  
    36.     dwret = SetSystemTime(st)
    37.     If dwret = 1 Then
    38. '
    39. ' This updates the Windows displaying the system time
    40. '
    41.         Call SendMessage(HWND_TOPMOST, WM_TIMECHANGE, 0, 0)
    42.     End If
    43. End Sub

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2002
    Location
    Memphis , TN
    Posts
    4
    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

  4. #4

    Thread Starter
    New Member
    Join Date
    Jan 2002
    Location
    Memphis , TN
    Posts
    4
    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
  •  



Click Here to Expand Forum to Full Width