Date Control
-
I'm using the date control on a dialog. When the dialog is displayed I need to set the day field of this control to be selected. Can anyone tell me how to do this? thanks, Andy
Are we talking about a CDateTimeCtrl here? Normaly, you call SetTime() on a control-variable of type CDateTimeCtrl you added to your dialog. This would require the time you want to set in a CTime or COleDateTime class or a SYSTEMTIME structure. Another, more complicated, way would be to send the control a DTM_SETSYSTEMTIME message.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal.
George Orwell, "Keep the Aspidistra Flying", Opening words -
I'm using the date control on a dialog. When the dialog is displayed I need to set the day field of this control to be selected. Can anyone tell me how to do this? thanks, Andy
Use GetMonthCalCtrl to get CMonthCalCtrl from a CDateTimeCtrl. Use SetCurSel to select a date. Sample from MSDN: CDateTimeCtrl* pCtrl = (CDateTimeCtrl*) GetDlgItem(IDC_DATETIMEPICKER1); CMonthCalCtrl* pMoCalCtrl = pCtrl->GetMonthCalCtrl(); CTime dt2(1998, 3, 15, 0, 0, 0); pMoCalCtrl->SetCurSel(dt2);
- NS -
-
I'm using the date control on a dialog. When the dialog is displayed I need to set the day field of this control to be selected. Can anyone tell me how to do this? thanks, Andy