I copied this Date Control off the forum, slightly modified it and merged it into my program. I was
wondering if someone could help me with the code to set the displayed date different from the defaulting
today's date. If no date has been selected, is it possible to incorporate this with a no-date selection?
I'd like use it with a multiple date entry for.
------------------
Henning
wondering if someone could help me with the code to set the displayed date different from the defaulting
today's date. If no date has been selected, is it possible to incorporate this with a no-date selection?
I'd like use it with a multiple date entry for.
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 GetDate(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, 80, 14, %WS_CHILD OR _ %WS_TABSTOP OR %WS_VISIBLE, 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 GetDate(sTime AS SYSTEMTIME) EXPORT AS STRING LOCAL tDay AS ASCIIZ * 64 GetDateFormat %LOCALE_USER_DEFAULT, %NULL, sTime, "MMddyyyy", tDay, 64 FUNCTION = tDay END FUNCTION '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ ' The main callback function for all controls '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ CALLBACK FUNCTION DlgCallback() LOCAL hdrX AS NMDATETIMECHANGE PTR SELECT CASE CBMSG 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: " & GetDate(@hdrX.st) END SELECT END SELECT END FUNCTION '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ ' The End '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
------------------
Henning
Comment