Date/Time Picker (VB6)

Is there any way to change the default starting day in the drop down calendar.
I tried setting the dayofweek but this didn't work.
When I drop down the calendar the first day is a Monday, I would prefer it to be a Sunday.
annandapAsked:
Who is Participating?
 
twardConnect With a Mentor Commented:
This will do it, but it will also change the text in the combobox:

Form1.DTPicker1.Day = "12"
Form1.DTPicker1.Refresh
0
 
SLECommented:
I don't think this is possible.
0
 
ventondCommented:
Two possible solutions:
1) The control that the DTPicker uses is called MonthView, it has this setting; "StartofWeek". Perhaps you can find a way of using this control.
2) Find a way of sending a message to the MonthView control within the dtpicker, Which I can't help you with.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
TimCotteeCommented:
I don't think you can do this either, you could use the monthview control which has a startofweek property that you can set to 1 (sunday) you could use this in conjunction with a combobox to provide similar functionality.
0
 
TimCotteeCommented:
tward, I just though I would try this but all it does is the obvious, sets the preselected day as the 12th of the current month.
0
 
twardCommented:
That is what I said in my answer..  I haven't tried the CCRP Control replacement for this, but it may do it:

http://www.mvps.org/ccrp/
0
 
TimCotteeCommented:
I had forgotten about the ccrp version. This does have a first day of week option which will provide the required function. Thanks tward for reminding me. I downloaded them a while back but forgot to look at it.
0
 
twardCommented:
Here is how you can do it with the VB Date Time Picker:

Public Const DTM_FIRST        As Integer = &H1000
Public Const DTM_GETMONTHCAL As Integer = (DTM_FIRST + 8)

Public Const MCM_FIRST           As Integer = &H1000
Public Const MCM_SETFIRSTDAYOFWEEK As Integer = (MCM_FIRST + 15)

Public Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Private Sub DTPicker1_DropDown()
 
  Dim hwnd As Long
 
  hwnd = SendMessageLong(Form1.DTPicker1.hwnd, DTM_GETMONTHCAL, 0, 0)

  Call SendMessageLong(hwnd, MCM_SETFIRSTDAYOFWEEK, 0, 0)
 
End Sub

**** The Second 0 in the Second SendMessageLong call sets the Day of Week 0 = Monday,1 = Tuesday.... 6 = Sunday.
0
 
twardCommented:
Here is how you can do it with the VB Date Time Picker:

Public Const DTM_FIRST        As Integer = &H1000
Public Const DTM_GETMONTHCAL As Integer = (DTM_FIRST + 8)

Public Const MCM_FIRST           As Integer = &H1000
Public Const MCM_SETFIRSTDAYOFWEEK As Integer = (MCM_FIRST + 15)

Public Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Private Sub DTPicker1_DropDown()
 
  Dim hwnd As Long
 
  hwnd = SendMessageLong(Form1.DTPicker1.hwnd, DTM_GETMONTHCAL, 0, 0)

  Call SendMessageLong(hwnd, MCM_SETFIRSTDAYOFWEEK, 0, 0)
 
End Sub

**** The Second 0 in the Second SendMessageLong call sets the Day of Week 0 = Monday,1 = Tuesday.... 6 = Sunday.
0
 
annandapAuthor Commented:
Thank you
0
All Courses

From novice to tech pro — start learning today.