Welcome Guest.   Make a donation to an author on the site December 21, 2014, 08:28:28 AM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
Your Support Funds this Site: View the Supporter Yearbook.
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: TimeDatePicker (Out Of) Control  (Read 1707 times)
Stoic Joker
Honorary Member
**
Posts: 5,449



View Profile WWW Give some DonationCredits to this forum member
« on: January 30, 2010, 03:10:03 PM »

Okay, as usual I'm working with pure Win32 API C++...

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...

My Code (relevent parts only):
Formatted for C++ with the GeSHI Syntax Highlighter [copy or print]
  1. SYSTEMTIME st[2]; // Used to Set Maximum DateTimePicker Control Date
  2.                 // That should give me a 2 element array of 0 & 1
  3. GetLocalTime(&st[1]); // This is Today...There IS NO Tomorrow...
  4. DateTime_SetRange(GetDlgItem(hDlg, IDCDT_CRS_ANALDATE), GDTR_MIN, &st[1]);
  5. 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
Jibz
Developer
***
Posts: 961



Cold Warrior

View Profile WWW Give some DonationCredits to this forum member
« Reply #1 on: January 30, 2010, 05:08:44 PM »

If the third parameter of the DateTime_SetRange macro is supposed to be a two-element array, shouldn't it be &st[0]?

When you specify GDTR_MIN it uses the first element, which works ok even though you point at the second, but when you specify GDTR_MAX it uses the second, which is outside the array if I understand it right.
« Last Edit: January 30, 2010, 05:10:38 PM by Jibz » Logged

"A problem, properly stated, is a problem on it's way to being solved" -Buckminster Fuller
"Multithreading is just one damn thing after, before, or simultaneous with another" -Andrei Alexandrescu
Stoic Joker
Honorary Member
**
Posts: 5,449



View Profile WWW Give some DonationCredits to this forum member
« Reply #2 on: January 30, 2010, 06:53:44 PM »

(Granted it's working now, but...) Either I'm completely retarded or somebody at MS needs to be beaten with a claw hammer.

Here's my train of thought:

SYSTEMTIME st[2]; <- array of two Items st[0] & st[1]

Which allows the assumption that:
GDTR_MIN = element 1 or st[0]
GDTR_MAX = element 2 or st[1]

So... (I'll drop to using only one control for clarity) ...This Should Work:

GetLocalTime(&st[0]); populate ele1
GetLocalTime(&st[1]); populate ele2

DateTime_SetRange(GetDlgItem(hDlg, IDCDT_CRS_ANALDATE), GDTR_MIN, &st[0]);
DateTime_SetRange(GetDlgItem(hDlg, IDCDT_CRS_ANALDATE), GDTR_MAX, &st[1]);

But it doesn't - However...

GetLocalTime(&st[1]); populate ele2 only

DateTime_SetRange(GetDlgItem(hDlg, IDCDT_CRS_ANALDATE), GDTR_MIN, &st[0]);
DateTime_SetRange(GetDlgItem(hDlg, IDCDT_CRS_ANALDATE), GDTR_MAX, &st[1]);

Results in MIN working & MAX Failing

Now the weird part...

GetLocalTime(&st[1]); Once again populate ele2 only

DateTime_SetRange(GetDlgItem(hDlg, IDCDT_CRS_ANALDATE), GDTR_MIN, &st[1]);
DateTime_SetRange(GetDlgItem(hDlg, IDCDT_CRS_ANALDATE), GDTR_MAX, &st[0]);

Results in both MIN & MAX Working, even tho st[0] is pointing at an empty array element.


...Now can anybody explain this? ...or do I need to go get a hammer?
Logged
Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.04s | Server load: 0.21 ]