如题,目的就是给时间空间设置一个非当前时间,比如设置成 2009-01-11
SetDlgItemText(IDC_DATETIMEPICKER1,"1975-07-01"); 这样不行
使用MSDN上SetTime的方法也不行,直接把MSDN上的例子拷过去执行也不能设置啊?

解决方案 »

  1.   

    CDateTimeCtrl::SetFormat("yyyy-MM");     "d" The one- or two-digit day.   
      "dd" The two-digit day. Single-digit day values are preceded by a zero.   
      "ddd" The three-character weekday abbreviation.   
      "dddd" The full weekday name.   
      "h" The one- or two-digit hour in 12-hour format.   
      "hh" The two-digit hour in 12-hour format. Single-digit values are preceded by a zero.   
      "H" The one- or two-digit hour in 24-hour format.   
      "HH" The two-digit hour in 24-hour format. Single-digit values are preceded by a zero.   
      "m" The one- or two-digit minute.   
      "mm" The two-digit minute. Single-digit values are preceded by a zero.   
      "M" The one- or two-digit month number.   
      "MM" The two-digit month number. Single-digit values are preceded by a zero.   
      "MMM" The three-character month abbreviation.   
      "MMMM" The full month name.   
      "t" The one-letter AM/PM abbreviation (that is, AM is displayed as "A").   
      "tt" The two-letter AM/PM abbreviation (that is, AM is displayed as "AM").   
      "yy" The last two digits of the year (that is, 1996 would be displayed as "96").   
      "yyyy" The full year (that is, 1996 would be displayed as "1996").  
      

  2.   

    CDateTimeCtrl*   pCtrl   =   (CDateTimeCtrl*)   GetDlgItem(IDC_DATETIMEPICKER1); 
          ASSERT(pCtrl   !=   NULL);       //   Set   with   CTime. 
          CTime   timeTime(1998,   4,   3,   0,   0,   0); 
          VERIFY(pCtrl-> SetTime(&timeTime));       //   Set   with   a   COleDateTime   object. 
          COleDateTime   oletimeTime(1998,   4,   3,   0,   0,   0); 
          VERIFY(pCtrl-> SetTime(oletimeTime));       //   Set   using   SYSTEMTIME. 
          SYSTEMTIME   sysTime; 
          memset(&sysTime,   0,   sizeof(sysTime)); 
          sysTime.wYear   =   1998; 
          sysTime.wMonth   =   4; 
          sysTime.wDay   =   3; 
          VERIFY(pCtrl-> SetTime(&sysTime)); 
      

  3.   

    CDateTimeCtrl time;  // 为你的时间控件绑定的变量
    COleDateTime t;  
    t.ParseDateTime(strdate);  
    m_date=t;
      

  4.   

    更正一下:
    CDateTimeCtrl time;
    COleDateTime t;
    t.PraseDateTime(strdate);
    time.SetTime(t);
      

  5.   


    CDateTimeCtrl* pTime = (CDateTimeCtrl*)GetDlgItem(IDC_DATETIMEPICKER1);
    ASSERT(pTime);
    CTime timeTime(2009, 1, 11, 0, 0, 0);
    pTime->SetTime(&timeTime);