更新时钟

编程入门 行业动态 更新时间:2024-10-12 01:24:57
本文介绍了更新时钟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

嗨; 我使用了MFC ToolBox中的时间选择器. 您能建议我如何按当前时间更新时间吗? (像一个真正的时钟)? 谢谢 Sb

Hi; I used the time picker from MFC ToolBox. Would you suggest me how Can I update the time by current time? (like a real clock)? Thank you; Sb

推荐答案

//我只需要在Dialog窗口上有一个时钟即可. 我会建议的, 使用静态文本框(例如,ID为IDC_YOURCLOCK), 其内容将被设置(GetDlgItem(IDC_YOURCLOCK)->SetWindowText(..)) 通过对话框的计时器反应中的格式化字符串. 您还可以在该框中设置任何样式和字体, 对于用户来说,它将保留为只读"时钟...:) // I just need to have a clock on the Dialog window. It will be suggested (by me), to use a static text box (for example with ID: IDC_YOURCLOCK), whose content will be set (GetDlgItem(IDC_YOURCLOCK)->SetWindowText(..)) by the formatted strings from the timer reaction of your dialog. You could also set any styles and fonts at that box, and it will stay as a "read only" clock for the users... :)

您的TimePicker应该具有一个名为Time(或DateTime)的属性.当您想更新控件(也许在计时器上)时,只需将该属性设置为当前时间/日期时间即可. (可能有一个SetTime或类似的方法.)确保刷新控件或其中的某个容器. Your TimePicker should have a property called Time (or maybe DateTime). When you want to update the control (maybe on a timer), just set that property to the current time/datetime. (There is probably a SetTime or some such method.) Make sure the control or some container of it is refreshed.

我只需要在Dialog窗口上有一个时钟即可. 正确的是,我从工具箱添加了TimePicker.现在,我可以在启动应用程序的任何时间坐下来.我想自动更新. 感谢您的帮助. SB I just neen to have a clock on the Dialog window. Right mow I add TimePicker from ToolBox. What I have now is sit at whatever time when I start the application. I want to update it automatically. Thanks for help. Sb

更多推荐

更新时钟

本文发布于:2023-11-27 14:17:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638415.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:时钟

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!