locked
MonthCalendar control RRS feed

  • Question

  • Hello all,

    I developed a VB application and in a form where a Monthcalendar is used I find a strange behavior. Only on a particular workstation, the Monthcalendar week days are shown in a "long" format and not in short/abbreviated format.

    Is there a Windows setting that handles the MonthCalendar week days format?

    Best

    Stefano Milanesi

    Friday, November 2, 2018 11:45 AM

All replies

  • The most likely reason is culture settings or the user customized formatting of date/time under control panel.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Friday, November 2, 2018 12:44 PM
  • MonthCalendar uses regional settings

    It calls GetCalendarInfo

    For example, it does something like this :

    Dim wsdayName As StringBuilder = New StringBuilder(32)
    For nDayOfWeek = 0 To 6
        Dim nRetCal As Integer = GetCalendarInfo(LOCALE_USER_DEFAULT, CAL_GREGORIAN, CAL_SABBREVDAYNAME1 + nDayOfWeek, wsdayName, 32, IntPtr.Zero)
        If (nRetCal = 0) Then
            Dim nErr As Integer = Marshal.GetLastWin32Error()
            Dim win32Exception = New System.ComponentModel.Win32Exception(nErr)
            Throw New ExternalException("Error: " & Convert.ToString(win32Exception.Message))
            Exit For
        Else
            Console.WriteLine(wsdayName)
        End If
    Next    

    with declarations :

        <DllImport("Kernel32.dll", SetLastError:=True, CharSet:=CharSet.Unicode)>
        Private Shared Function GetCalendarInfo(ByVal Locale As UInteger, ByVal Calendar As UInteger, ByVal CalType As Integer, ByVal lpCalData As StringBuilder, ByVal cchData As Integer, ByVal lpValue As IntPtr) As Integer
        End Function
    
        Public Const LOCALE_USER_DEFAULT = &H400
        Public Const CAL_GREGORIAN = 1
        Public Const CAL_SABBREVDAYNAME1 = &HE

    Friday, November 2, 2018 12:56 PM
  • Yes it is true but the problem is that I didn't find any Windows settings (Control Panel) that sets MonthCalendar weekdays format (short/long format)

    Best

    stefano

    Friday, November 2, 2018 3:01 PM
  • Yes it is true but the problem is that I didn't find any Windows settings (Control Panel) that sets MonthCalendar weekdays format (short/long format)

    Best

    stefano

    You mean Operating System settings? Here is mine for windows 7. Yours may be different.

    Friday, November 2, 2018 4:10 PM
  • I have already changed several times these settings but the weekdays in the Calendar control are display as always:


    Best

    Stefano

    Friday, November 2, 2018 4:21 PM
  • I have already changed several times these settings but the weekdays in the Calendar control are display as always:


    Best

    Stefano

    Is that the language setting? You need to change the language which is there on the regional?? In fact there is the date again??

    Friday, November 2, 2018 4:25 PM
  • Under Windows 10


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Friday, November 2, 2018 4:30 PM
  • the problem occurs on client's workstation (not on my development PC).

    this workstation has the Windows setting Calendar as follow (see weekdays format-  2 characters):

    but MonthCalendar control (on the same workstation) in windows form is shown as following (see weekdays format):

    All the others client's workstations have no problem, the MonthCalendar control is shown correctly (see weekdays format):

    Friday, November 2, 2018 4:39 PM
  • but MonthCalendar control (on the same workstation) in windows form is shown as following (see weekdays format):

    All the others client's workstations have no problem, the MonthCalendar control is shown correctly (see weekdays format):

    Oh, you know what? That is the control panel dpi or size setting for the monitor. One is prob high res or what ever and the control panel display text size is on like 150 %

    :)

    Ps oh wait maybe not. What do you mean? Show what is wrong exactly.

    And what windows versions and is xp styles enabled?
    Friday, November 2, 2018 5:06 PM
  • It is not a "scale and layout" / resolution settings issue, the workstation has this setting:


    the problem is that the weekdays are shown in "long" format and not in "short" format as all the other workstations

    Best

    Stefano

    Friday, November 2, 2018 5:23 PM
  • I see.

    Well just guessing along with you.

    If it is the same res then why do the calandar image widths look different? ie the one on top with the long? weekday is almost twice the width of the one on bottom with short weekday? Does that make the weekday fill the space long or something? But why is it wider than the other?

    Friday, November 2, 2018 6:08 PM
  • Friday, November 2, 2018 7:57 PM
  • I asked myself the same questions and I had the same doubs. My opinion is tha the calendar having the days of the week so long automatically its size increases considerabily.

    This is my idea/opinion (having discarded problems of resolution etc ...)

    Best

    Stefano

    Friday, November 2, 2018 8:51 PM
  • I asked myself the same questions and I had the same doubs. My opinion is tha the calendar having the days of the week so long automatically its size increases considerabily.

    This is my idea/opinion (having discarded problems of resolution etc ...)

    Best

    Stefano

    Did you look at the link Viorel found?

    It sounds like the same problem. More of a bug.

    Friday, November 2, 2018 10:58 PM
  • I'll look into un-updated intermediate version of Windows issue

    I'll keep you informed

    Best

    Stefano

    Monday, November 5, 2018 8:03 AM
  • I'll look into un-updated intermediate version of Windows issue

    I'll keep you informed

    Best

    Stefano

    Hi,

    Do you resolve the issue? 

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, November 7, 2018 8:07 AM
  • Hello,

    I have forwarded all the information to the helpdesk now, I'm still waiting for their answer

    When I have news, I will write

    Thanks

    Stefano

    Wednesday, November 7, 2018 8:17 AM
  • Hello all,

    helpdesk read the article and checked the PC situation/settings/version but did not detect any "problem". On the same PC, by setting the English format in the control panel, the calendar has no problems.

    Best

    Stefano

    Monday, November 12, 2018 8:32 AM