<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="https://syndication.webwiz.net/rss_namespace/">
 <channel>
  <title>Codejock Developer Community : How To Show Week Numbers in DateTimePicker</title>
  <link>http://forum.codejock.com/</link>
  <description><![CDATA[This is an XML content feed of; Codejock Developer Community : Visual Basic Code Snippets : How To Show Week Numbers in DateTimePicker]]></description>
  <copyright>Copyright (c) 2006-2013 Web Wiz Forums - All Rights Reserved.</copyright>
  <pubDate>Thu, 14 May 2026 04:15:36 +0000</pubDate>
  <lastBuildDate>Wed, 02 Feb 2011 08:38:36 +0000</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 12.04</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>forum.codejock.com/RSS_post_feed.asp?TID=17826</WebWizForums:feedURL>
  <image>
   <title><![CDATA[Codejock Developer Community]]></title>
   <url>http://forum.codejock.com/forum_images/codejock-logo.gif</url>
   <link>http://forum.codejock.com/</link>
  </image>
  <item>
   <title><![CDATA[How To Show Week Numbers in DateTimePicker : Hi,I know some people have asked...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=17826&amp;PID=62397&amp;title=how-to-show-week-numbers-in-datetimepicker#62397</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=2960">Xander75</a><br /><strong>Subject:</strong> 17826<br /><strong>Posted:</strong> 02 February 2011 at 8:38am<br /><br />Hi,<br><br>I know some people have asked for Codejock to implement this in their DateTimePicker control so I thought I would add the code here on how to show week numbers until they implement it as an option. This also works with the Microsoft DatePicker control.<br><br><img src="uploads/2960/WeekNumbers.png" height="238" width="317" border="0" /><br><br>Add the code snippet below to a module:<br><table width="99%"><tr><td><pre class="BBcode"><br>Option Explicit<br><br>Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long<br>Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long<br><br>Public Const GWL_STYLE = (-16)<br><br>' MonthCalendar specific constants. Requires comctl32.dll ver. 4.70<br>Public Const MCM_FIRST = &amp;H1000<br>Public Const MCM_GETMINREQRECT = (MCM_FIRST + 9)<br>Public Const MCS_WEEKNUMBERS = &amp;H4<br><br>' DateTime Picker specific constants. Requires comctl32.dll ver. 4.70<br>Public Const DTM_FIRST = &amp;H1000<br>Public Const DTM_GETMONTHCAL = (DTM_FIRST + 8)<br><br>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<br>Public Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long<br><br>Public Type RECT<br>&nbsp;&nbsp; Left As Long<br>&nbsp;&nbsp; Top As Long<br>&nbsp;&nbsp; Right As Long<br>&nbsp;&nbsp; Bottom As Long<br>End Type<br></pre></td></tr></table><br><br>Then add the following into the DropDown event of the DateTimePicker control:<br><table width="99%"><tr><td><pre class="BBcode"><br>Private Sub DateTimePicker_DropDown()<br>&nbsp;&nbsp; Dim objStyle As Long<br>&nbsp;&nbsp; Dim objRect As RECT<br>&nbsp;&nbsp; Dim hCal As Long<br><br>&nbsp;&nbsp; ' Get the handle to the DropDown Calendar<br>&nbsp;&nbsp; hCal = SendMessage(DateTimePicker.hwnd, DTM_GETMONTHCAL, 0, 0)<br>&nbsp;&nbsp; ' If hCal is greater than zero then the MonthCalendar exists<br>&nbsp;&nbsp; If hCal &gt; 0 Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' Get the current style of the DropDown Calendar:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objStyle = GetWindowLong(hCal, GWL_STYLE)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' ..and add the WeekNumber style..<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objStyle = objStyle Or MCS_WEEKNUMBERS<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' Set the new style in the DropDown Calendar<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Call SetWindowLong(hCal, GWL_STYLE, objStyle)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' Get the minimum size of the DropDown calendar that will show all<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' of the calendar.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SendMessage hCal, MCM_GETMINREQRECT, 0, objRect<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' ..and size the DropDown calendar to the size required.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MoveWindow hCal, 0, 0, objRect.Right + 2, objRect.Bottom, True<br>&nbsp;&nbsp; End If<br>End Sub<br></pre></td></tr></table><br>]]>
   </description>
   <pubDate>Wed, 02 Feb 2011 08:38:36 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=17826&amp;PID=62397&amp;title=how-to-show-week-numbers-in-datetimepicker#62397</guid>
  </item> 
 </channel>
</rss>