|
-
October 19th, 2010, 07:32 AM
#16
Re: Month Calendar : output selected range to MessageBox - pls explain
Then what is the MonthCal_GetSelRange() for? Shouldn't there be a way to pass it's contents, of the 2 element array of SYSTEMTIME structures?? Or at least handle them for processing in some way?
-
October 19th, 2010, 07:36 AM
#17
Re: Month Calendar : output selected range to MessageBox - pls explain
 Originally Posted by Morbane
Then what is the MonthCal_GetSelRange() for? Shouldn't there be a way to pass it's contents, of the 2 element array of SYSTEMTIME structures?? Or at least handle them for processing in some way?
Didn't you read the MSDN about MonthCal_GetSelRange? 
MonthCal_GetSelRange
Retrieves date information that represents the upper and lower limits of the date range currently selected by the user. You can use this macro or send the MCM_GETSELRANGE message explicitly.
And it's up to you where and how to use the returned SYSTEMTIME array with these "upper and lower limits of the date range currently selected by the user".
Victor Nijegorodov
-
October 19th, 2010, 08:59 AM
#18
Re: Month Calendar : output selected range to MessageBox - pls explain
Ok...
I have managed to isolate the lower and upper ranges of MonthCal_GetSelRange(), thus:
Code:
SYSTEMTIME rng[2];
MonthCal_GetSelRange(hWndMonthCal, rng);
SYSTEMTIME low = rng[0];
SYSTEMTIME high = rng[1];
char buf1[30];
GetDateFormat(NULL, DATE_LONGDATE, &low, NULL, buf1, 30);
char buf2[30];
GetDateFormat(NULL, DATE_LONGDATE, &high, NULL, buf2, 30);
MessageBox(hwndDlg, buf, "Current Date", 0);
How do I get buf1 and buf2 into the MessageBox as a single unit with a pretty "to" in between?
-
October 19th, 2010, 09:07 AM
#19
Re: Month Calendar : output selected range to MessageBox - pls explain
1. Why not just pass in the rng[0], rng[1]? Example:
Code:
char buf1[30];
GetDateFormat(NULL, DATE_LONGDATE, &rng[0, NULL, buf1, 30);
2.
Code:
char buf[100];
strcpy(buf, buf1);
strcat(buf, " to ");
strcat(buf, buf2);
MessageBox(hwndDlg, buf, "Current Date", 0);
Victor Nijegorodov
-
October 19th, 2010, 09:22 AM
#20
Re: Month Calendar : output selected range to MessageBox - pls explain
Very NICE indeed.
I looked at strcat and the example in cplusplus.com/reference, but I hesitated, I wasn't sure about how it would work. It was exactly what I needed nevertheless.
Thanks again (and again 
Just by the by, in my calendar, if someone were to only select 1 day - the output remains twofold, in such a case it says October 19, 2010 to October 19, 2010. Is there a way to prevent that duplication? I haven't explored that yet but I thought I would ask anyway.
-
October 19th, 2010, 09:45 AM
#21
Re: Month Calendar : output selected range to MessageBox - pls explain
So I tried this:
Code:
if(buf1 == buf2)
{
MessageBox(hwndDlg, buf1, "Current Date", 0);
}
else
{
MessageBox(hwndDlg, buf, "Current Range", 0);
}
But it doesn't work - the logic is messed up somehow.
Any suggestions?
-
October 19th, 2010, 09:52 AM
#22
Re: Month Calendar : output selected range to MessageBox - pls explain
 Originally Posted by Morbane
So I tried this:
Code:
if(buf1 == buf2)
...
But it doesn't work - the logic is messed up somehow.
Of course it doesn't!
Because you compare the values of two pointers which are absolutely different!
You have to compare SYSTEMTIME objects (rng[0] and rng[1] in your case)
Victor Nijegorodov
-
October 19th, 2010, 10:18 AM
#23
Re: Month Calendar : output selected range to MessageBox - pls explain
When I try to use:
Code:
if(rng[0] == rng[1])
...
It says "there is no match for operator== for rng[0] == rng[1]"
I know about overloading operators - but I do not know how or if it necessary.
Or I am doing something wrong again.
Any suggestions?
Again, Thanks.
-
October 19th, 2010, 10:29 AM
#24
Re: Month Calendar : output selected range to MessageBox - pls explain
Ok, then compare each member of SYSTEMTIME that makes sense for you. Like:
Code:
SYSTEMTIME rng[2];
...
if( rng[0].wYear == rng[1].wYear &&
rng[0].wMonth == rng[1].wMonth &&
rng[0].wDay == rng[1].wDay )
{
MessageBox(hwndDlg, buf1, "Current Date", 0);
}
...
Victor Nijegorodov
-
October 19th, 2010, 10:59 AM
#25
Re: Month Calendar : output selected range to MessageBox - pls explain
Victor, you are amazing.
I have experimented with the SYSTEMTIME members in various efforts to get this worked out, but at this point, it is quite late here and I don't think I would have thought of it on my own in this case.
Many thanks.
See you next time, no doubt I will be back for more insights.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|