CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 25 of 25
  1. #16
    Join Date
    Oct 2010
    Location
    Australia
    Posts
    98

    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?

  2. #17
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Month Calendar : output selected range to MessageBox - pls explain

    Quote Originally Posted by Morbane View Post
    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

  3. #18
    Join Date
    Oct 2010
    Location
    Australia
    Posts
    98

    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?

  4. #19
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    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

  5. #20
    Join Date
    Oct 2010
    Location
    Australia
    Posts
    98

    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.

  6. #21
    Join Date
    Oct 2010
    Location
    Australia
    Posts
    98

    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?

  7. #22
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Month Calendar : output selected range to MessageBox - pls explain

    Quote Originally Posted by Morbane View Post
    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

  8. #23
    Join Date
    Oct 2010
    Location
    Australia
    Posts
    98

    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.

  9. #24
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    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

  10. #25
    Join Date
    Oct 2010
    Location
    Australia
    Posts
    98

    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.

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured