Announcement

Collapse
No announcement yet.

Calendar control

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

  • Calendar control

    i posted an update to the calendar control.

    my question on this, since i cannot obviously adjust a pointer, is how do i set the calendar one year ahead so thhat it can be used to set an expiration date on a program?

    the main program uses this calendar control to set an expiration date on a second program..

    i attempted to do something like

    incr @xhdr.st.wyear but it obviously gpf'd on me....

    see this link for the control:

    http://www.powerbasic.com/support/pb...ad.php?t=23045


    ------------------
    scott
    mailto:[email protected][email protected]</a>
    Scott Turchin
    MCSE, MCP+I
    http://www.tngbbs.com
    ----------------------
    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

  • #2
    Scott,
    see the code added in %WM_INITDIALOG.

    Code:
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' A small DDT example of how to create and use Commctrl's Calendar.
    ' Written by Borje Hagsten. Updated by Scott Turchin for easier formatting of output
    ' Public Domain = free To use And modify.
    ' Ideas for usage: Databases of all kinds, "Insert date" functions
    ' in text editors, diaries, PIMs, etc..  :-) Or setting the expiration date on an application
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    #Compile Exe
    #Include "WIN32API.INC"
    #Include "COMMCTRL.INC"
    
    %ID_LABEL    = 10
    %ID_CALENDAR = 20
    
    Declare CallBack Function DlgCallback()
    Declare Function GetTimeandDate(sTime As SYSTEMTIME) As String
    
    
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' PBMAIN - build dialog and controls
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    Function PbMain
        Dim hDlg As Long
    
        Local iccex As INIT_COMMON_CONTROLSEX  'Initialize the calendar
        iccex.dwSize = SizeOf(iccex)
        iccex.dwICC = %ICC_DATE_CLASSES
        Call InitCommonControlsEx(iccex)
    
        Dialog New 0, "Calendar demo",,, 196, 60, %WS_SYSMENU To hDlg
        Control Add Label, hDlg, %ID_LABEL, "Click at the Combo's down arrow.", 6, 30, 180, 14
        Control Add Button, hDlg, %IDCANCEL, "&Close", 134, 6, 50, 14
    
        Control Add "SysDateTimePick32", hDlg, %ID_CALENDAR, "", 6, 6, 120, 14, %WS_CHILD Or _
            %WS_TABSTOP Or %WS_VISIBLE Or %DTS_LONGDATEFORMAT, , Call DlgCallback
        'Note: You can also use "SysMonthCal32", to get the calendar only,
        '      but then you also have to set the height to e.g. 100 ..  :-)
        'See Commctrl.inc for other useful Constants and Type structures
    
        Dialog Show Modal hDlg Call DlgCallback
    End Function
    
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    'Format your output as you like
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    Function GetTimeandDate(sTime As SYSTEMTIME) Export As String
    Local tDay              As Asciiz * 64
    Local tTime             As Asciiz * 64
    GetDateFormat %LOCALE_USER_DEFAULT, %NULL, sTime, "MMM dd',' yyyy", tDay, 64       'Use this to format the date
    GetTimeFormat %LOCALE_SYSTEM_DEFAULT, %TIME_NOSECONDS,sTime, ByVal %NULL, tTime, 64 'Use this to format the time
    Function = tDay + " " + tTime
    End Function
    
    
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' The main callback function for all controls
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    CallBack Function DlgCallback()
    Local hdrX As NMDATETIMECHANGE Ptr, ST As SystemTime, lRet As Long
    
    
       Select Case CbMsg
            Case %WM_INITDIALOG
              GetLocalTime ST
              Incr ST.wYear
              Control Send CbHndl, %ID_CALENDAR, %DTM_SETSYSTEMTIME, 0, VarPtr(ST) To LRet  '
            Case %WM_COMMAND
             If CbCtl = %IDCANCEL Then Dialog End CbHndl, (CbCtl = %IDOK)
    
            Case %WM_NOTIFY
             'Use this to detect changes in the calendar
             hdrX = CbLparam
             Select Case @hdrX.hdr.code
                    Case %DTN_CLOSEUP
                    Case %DTN_DROPDOWN
                    Case %DTN_DATETIMECHANGE  'Get selected date/time
                        If @hdrx.dwFlags <> %GDT_VALID Then Exit Function 'Trust but verify SYSTEMTIME STRUCTURE
                        Control Set Text CbHndl, %ID_LABEL, "Selected Date: " & GetTimeandDate(@hdrX.st)
    
             End Select
    
       End Select
    End Function
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' The End
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ------------------
    Peter.
    mailto[email protected][email protected]</A>
    Regards,
    Peter

    Comment


    • #3
      Works like a charm!
      Thanks!
      I was trying to use a pointer to do the Control Send with...

      Scott


      ------------------
      Scott
      mailto:[email protected][email protected]</A>
      Scott Turchin
      MCSE, MCP+I
      http://www.tngbbs.com
      ----------------------
      True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

      Comment

      Working...
      X