CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 1999
    Posts
    171

    Date Time Picker Problem

    I used a Date Time Picker control & mapped value to CTime. The default value in the control when I run the app is 12/31/69. Works fine until I change the date in the control. Then get ASSERT failure. I traced the code after returning from DoModal(). MFC calls DoDataExchange() which calls DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER, m_tDate); (m_tDate is dialog variable of type CTime. Assert fails when CTime constructor in MFC's file TimeCore.cpp is called at Line 40 . . . ASSERT(m_time != -1);. Any ideas. Thanks very much for anyone's input.
    PS. I just learned that it fails only when I change the month or day. I can change the year without the assert failure. (?)


  2. #2
    Join Date
    Jun 1999
    Location
    San Diego, CA
    Posts
    600

    Re: Date Time Picker Problem

    CTime is defined only between the first strike of new year of 1970 and the time bomb explodes on Jan. 18, 2038. I would avoid using CTime in my program.

    When your control is initialized to Dec. 31, 1969, any slight change to the month or day yields a date value that's beyond the valid definition range of CTime. I would be surprised if that didn't cause problem.

    Don't use MFC's DDX. Do your own. And use COleDateTime instead.


    I hate fat programs as much as I hate being fat myself. I am lean and mean and so is my program.

  3. #3
    Join Date
    Aug 1999
    Posts
    171

    Re: Date Time Picker Problem

    Anthony,
    Thanks! You were right. Any date in 1969 is invalid & the assert failure is triggered. Will experiment with the COleDateTime class. I haven't used any Ole controls. Thanks again for your quick reply.
    Trader


  4. #4
    Join Date
    Aug 1999
    Posts
    171

    Re: Date Time Picker Problem

    One more question. When you say, "Don't use MFC's DDX. Do your own." . . . do you still call the applicable DDX??? function from within the DoDateExchange function wrote by the AppWizard? Do I just call it outside of the /{{AFX_DATA_MAP labels? Thanks again.





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