开发者

How to set MFC time/date control to 24 hour time

I am trying to get a CDateTimeCtrl control in a dlg box to show 24 hour time format rather than 开发者_JAVA技巧am/pm nonsense.

I would have thought there was a flag for this, but MS decided NOT to provide one.

Is it possible?


Even though CDateTimeCtrl doesn't provide a class method to change the format, the class itself wraps the Win32 date and time picker which does allow you to set a custom format. You can do this by sending a message directly to the control:

DateTime_SetFormat(m_dateTime.m_hWnd, TEXT("HH:mm:ss"));

Edit: As @Kirill V. Lyadvinsky points out, you can simply use the CDateTimeCtrl::SetFormat method -- I somehow missed that when I was looking at the reference.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜