Re: Time show question
Are you sure that you are using the correct variable for the window you are
hoping to upgrade. Maybe m_sTime is hooked into the wrong window as a
control variable?
Also, you could try using CTime::Format to create the string as well. That
shouldn't make any difference in this case, but...
I'd start by checking my DDX variable and making sure that perhaps a
different string variable wasn't being used by accident (like you set up
m_sTime in your class object, but then created m_csTime in the DDX? Just
guessing. Also, if you try to compile this as Unicode you'd likely get
string errors so you may want to start using _T() around the static strings
like:
m_sTime.Format(_T("%d:%d:%d"),curTime.GetHour(),curTime.GetMinute(),curTime.GetSecond());
Since CString does some automatic string conversions you may be seeing a
problem in that area as well.
Tom
"redphoenix" <rodphoenix@163.com> wrote in message
news:%232ydybmcJHA.2444@TK2MSFTNGP06.phx.gbl...
I have a IDC_STATIC and add variable,type is CString and name is 'm_sTime'
Then I use Class Wizard and add a function to WM_TIMER,like follows:
void CTimersDlg::OnTimer(UINT_PTR nIDEvent)
{
// TODO: Add your message handler code here and/or call default
CTime curTime=CTime::GetCurrentTime();
m_sTime.Format("%d:%d:%d",curTime.GetHour(),curTime.GetMinute(),curTime.GetSecond());
UpdateData(FALSE); CDialog::OnTimer(nIDEvent);}When I run it,it should
show time,such as 15:25:23,but it shows 1243860:139,where is wrong? How to
modify it? I use VC2008.Thanks.