I'm trying to set the maximum selectable date for a DateTimePicker (Calendar) control - and it ain't working.
MSDN Says:
Quote
hwndDT
Handle to a DTP control.
flags
Value that specifies which range values are valid. This value can be a combination of the following:
GDTR_MIN
The first element in the SYSTEMTIME structure array is valid and will be used to set the minimum allowable system time.
GDTR_MAX
The second element in the SYSTEMTIME structure array is valid and will be used to set the maximum allowable system time.
lpSysTimeArray
Pointer to a two-element array of SYSTEMTIME structures. The first element of the SYSTEMTIME array contains the minimum allowable time. The second element of the SYSTEMTIME array contains the maximum allowable time. It is not necessary to fill an array element that is not specified in the flags parameter.
More on the bold part later...Handle to a DTP control.
flags
Value that specifies which range values are valid. This value can be a combination of the following:
GDTR_MIN
The first element in the SYSTEMTIME structure array is valid and will be used to set the minimum allowable system time.
GDTR_MAX
The second element in the SYSTEMTIME structure array is valid and will be used to set the maximum allowable system time.
lpSysTimeArray
Pointer to a two-element array of SYSTEMTIME structures. The first element of the SYSTEMTIME array contains the minimum allowable time. The second element of the SYSTEMTIME array contains the maximum allowable time. It is not necessary to fill an array element that is not specified in the flags parameter.
My Code (relevent parts only):
Formatted for C++ with the GeSHI Syntax Highlighter [copy or print]
SYSTEMTIME st[2]; // Used to Set Maximum DateTimePicker Control Date // That should give me a 2 element array of 0 & 1 GetLocalTime(&st[1]); // This is Today...There IS NO Tomorrow... DateTime_SetRange(GetDlgItem(hDlg, IDCDT_CRS_ANALDATE), GDTR_MIN, &st[1]); DateTime_SetRange(GetDlgItem(hDlg, IDCDT_CRS_PRODATE), GDTR_MAX, &st[1]);
Now, no matter WTF I do GDTR_MAX has no effect. Regardless of how I try to define this mythical array element 2 item... GDTR_MIN works fine, even if (as mentioned above) array element is left empty. I have to be able to (lock out cheaters) set the Maxamum selectable date to the current day. Code above works perfectly for the minimum date value (even tho it should not), and has no effect on the max.
Note: ultimately both controls will be set to/with/by GDTR_MAX only... I'm only using GDTR_MIN for testing/demonstration purposes.
What Am I Missing?!?!?!?









Logged




