Jump to content

Recommended Posts

Posted (edited)

Is there any Control which allows me to select only Month/Year? I really like the way the DTP looks if you click once on the month/year like the screenshot below.

image.png.f36a8eaaeb308c5067ad30ba0094be37.png I'd like to use it like this without any option for the user to see the DTP

like this: image.png.082987de98dfd7b8633e4d3c6df48d6b.png which is the default view.

Unfortunately I only found: GUICtrlCreateDate / GUICtrlCreateMonthCal / _GUICtrlDTP_Create and all seem to have no option to hide the day-view.

Edited by Yaerox
Posted

Ya I have worked on this in the past :

#include <Constants.au3>
#include <GUIConstants.au3>
#include <WinAPISysWin.au3>

Opt("MustDeclareVars", 1)

MsgBox ($MB_SYSTEMMODAL,"",MonthCalendar())

Func MonthCalendar($iLeft = -1, $iTop = -1)
  Local Const $asMonth[12] = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
  Local Const $cHighlight = 0xD6E0FF

  Local $hGUI = GUICreate("", 250, 150, $iLeft, $iTop, $WS_POPUP + $WS_BORDER)
  Local $iPrev = GUICtrlCreateLabel(ChrW(0x25C0), 25, 15, 25, 25, $SS_CENTER)
  GUICtrlSetFont(-1, 16)
  Local $iNext = GUICtrlCreateLabel(ChrW(0x25B6), 205, 15, 25, 25, $SS_CENTER)
  GUICtrlSetFont(-1, 16)
  Local $iYear = GUICtrlCreateLabel(@YEAR, 100, 21, 50, 25, $SS_CENTER)
  Local $aiMonth[12], $i = 0
  For $y = 0 To 2
    For $x = 0 To 3
      $aiMonth[$i] = GUICtrlCreateLabel($asMonth[$i], 50 * $x + 38, 30 * $y + 50, 30, 20, $SS_CENTER + $SS_CENTERIMAGE)
      GUICtrlSetFont(-1, 10)
      $i += 1
    Next
  Next
    GUISetState(@SW_SHOW)

  $i = Int(@MON) - 1
  GUICtrlSetBkColor($aiMonth[$i], $cHighlight)

  Local $iOK = GUICtrlCreateDummy ()
  Local $aAccelKeys[1][2] = [["{ENTER}", $iOK]]
  GUISetAccelerators($aAccelKeys)

  Local $nMsg

  While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
      Case $GUI_EVENT_CLOSE
        GUIDelete ()
        Return ("")
      Case $iPrev
        GUICtrlSetData($iYear, GUICtrlRead($iYear) - 1)
      Case $iNext
        GUICtrlSetData($iYear, GUICtrlRead($iYear) + 1)
      Case $aiMonth[0] To $aiMonth[11]
        If $i = $nMsg - $aiMonth[0] Then ContinueLoop
        GUICtrlSetBkColor($nMsg, $cHighlight)
        GUICtrlSetBkColor($aiMonth[$i], Default)
        $i = $nMsg - $aiMonth[0]
      Case $iOK
        Local $sReturn = GUICtrlRead($iYear) & "|" & $i + 1
        GUIDelete()
        Return $sReturn
    EndSwitch
  WEnd
EndFunc   ;==>MonthCalendar

 

Posted

So far this looks promising. Do you accidentally have another way to add a faster year-picking as well?

image.png.116f91d17b2adaa7232a8809316632be.png

This is for some GUI I build for automotive. So you have to set First-Registration which is MM/YYYY but let's say the car is 15 years old, I had to click on the year picker 15 times. Since it quite late now, I'd take myself a deeper look onto it tomorrow. So far thank you sir!

Posted (edited)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...