Announcement

Collapse
No announcement yet.

DateTimePicker: Dropdown-Fenster vergrößern

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • DateTimePicker: Dropdown-Fenster vergrößern

    Hallo zusammen,

    ich habe vor langer Zeit mal mein Kalender-Control um die Anzeige der Wochennummer durch ein Code-Snippet erweitert.
    Hier das Snippet:
    [highlight=vb.net]
    #Region "Kalenderwochen"


    ' Der Inhalt der folgenden Funktionen erweitert den DateTimePicker um das Property "ShowWeekNumbers".
    ' Wenn dieses auf TRUE steht werden die Kalenderwochen im DateTimePicker-Popup angezeigt.


    Public Declare Auto Function GetWindowLong Lib "user32.dll" ( _
    ByVal hWnd As IntPtr, _
    ByVal nIndex As Int32 _
    ) As Int32


    Private Declare Auto Function SetWindowLong Lib "user32.dll" ( _
    ByVal hWnd As IntPtr, _
    ByVal nIndex As Int32, _
    ByVal dwNewLong As Int32 _
    ) As Int32


    Private Const GWL_STYLE As Int32 = (-16)


    Private Const MCM_FIRST As Int32 = &H1000
    Private Const MCM_GETMINREQRECT As Int32 = (MCM_FIRST + 9)
    Private Const MCS_WEEKNUMBERS As Int32 = &H4


    Private Const DTM_FIRST As Int32 = &H1000
    Private Const DTM_GETMONTHCAL As Int32 = (DTM_FIRST + 8)


    Private Declare Auto Function SendMessage Lib "user32.dll" ( _
    ByVal hWnd As IntPtr, _
    ByVal uMsg As Int32, _
    ByVal lParam As Int32, _
    ByVal lpData As Int32 _
    ) As IntPtr


    Private Declare Auto Function SendMessage Lib "user32.dll" ( _
    ByVal hWnd As IntPtr, _
    ByVal uMsg As Int32, _
    ByVal lParam As Int32, _
    ByRef lpData As Rectangle _
    ) As Int32


    Private Declare Function MoveWindow Lib "user32.dll" ( _
    ByVal hwnd As IntPtr, _
    ByVal x As Int32, _
    ByVal y As Int32, _
    ByVal nWidth As Int32, _
    ByVal nHeight As Int32, _
    ByVal bRepaint As Boolean _
    ) As Int32


    Private m_ShowWeekNumbers As Boolean


    ''' <summary>
    ''' Ruft einen Wert ab, der angibt, ob die Kalenderwochen angezeigt werden müssen, oder legt diesen fest. Der Standardwert ist false.
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    < _
    Browsable(True), _
    DesignerSerializationVisibility( _
    DesignerSerializationVisibility.Visible _
    ) _
    > _
    Public Property ShowWeekNumbers() As Boolean
    Get
    Return m_ShowWeekNumbers
    End Get
    Set(ByVal Value As Boolean)
    m_ShowWeekNumbers = Value
    End Set
    End Property


    Protected Overloads Overrides Sub OnDropDown(ByVal e As EventArgs)
    Dim hMonthView As IntPtr = _
    SendMessage(Me.Handle, DTM_GETMONTHCAL, 0, 0)
    Dim dwStyle As Int32 = GetWindowLong(hMonthView, GWL_STYLE)
    If Me.ShowWeekNumbers Then
    dwStyle = dwStyle Or MCS_WEEKNUMBERS
    Else
    dwStyle = dwStyle And Not MCS_WEEKNUMBERS
    End If
    Dim rct As Rectangle
    SetWindowLong(hMonthView, GWL_STYLE, dwStyle)
    SendMessage(hMonthView, MCM_GETMINREQRECT, 0, rct)
    MoveWindow(hMonthView, 0, 0, rct.Right + 2, rct.Bottom, True)
    MyBase.OnDropDown(e)
    End Sub
    #End Region
    [/highlight]

    Das ganze hat soweit auch sehr gut funktioniert.
    Jetzt wurde gewünscht, dass der TreeView der Anwendung so aussieht, wie der Explorer in Win 7
    Dies habe ich durch einen Eintrag ins app.manifest
    [highlight=xml]
    <dependency>
    <dependentAssembly>
    <assemblyIdentity
    type="win32"
    name="Microsoft.Windows.Common-Controls"
    version="6.0.0.0"
    processorArchitecture="*"
    publicKeyToken="6595b64144ccf1df"
    language="*"
    />
    </dependentAssembly>
    </dependency>
    [/highlight]

    Irgendwas daran hat jetzt Einfluss auf das Kalender-Control und der Sonntag ist nicht mehr zu sehen.
    Gibt es eine Möglichkeit das Teil größer zu machen, so dass wieder alles sichtbar ist?

    Danke schonmal
    Andreas
Working...
X