MFC CEdit Ctrl 问题

发布于 2024-07-30 14:54:34 字数 376 浏览 3 评论 0原文

我有一个 CEdit 控件,我希望能够从中获取时间输入。 现在我希望输入的格式为 hh:mm:ss。 目前我正在使用单独的 CEdit 控件来显示小时、分钟和时间。 秒。 我知道我可以要求用户输入冒号来分隔小时、分钟、秒,但我相信这会让我的用户感到困惑。

我实际上希望我的控件显示冒号,并将控件的不同部分设置为制表位,以便用户清楚他们输入的具体时间。我知道我在其他地方看到过这一点,我只是我自己不知道该怎么做。

理想情况下,这些将作为 3 个单独的字符串出现,因为我没有使用 Epoch 时间或任何其他类型的系统时间,而是使用我自己的时间计数。 (即我们在文件中有多少数据样本。)这意味着每次,我的时钟从零开始,并从那里开始计数。

谢谢丹

I have a CEdit control that I want to be able to take time input from. Now I want this input to come in the form hh:mm:ss. Currently I am using a separate CEdit control for hour, mins, & secs. I know I could require the user enter in colons to separate hours, mins, secs, but this I believe will get confusing for my users.

I actually want my control to show the colons, and have the different sections of the control to be tab stops, so that it is clear to the user what time exactly they are entering in. I know I have seen this elsewhere, and I just don't know how to do it myself.

Ideally these would come in as 3 separate strings, because I am not using Epoch time, or any other type of system time, but am using my own time count. (ie. how many data samples we are into the file.) Meaning each time, my clock starts at zero, and counts up from there.

Thanks

Dan

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

维持三分热 2024-08-06 14:54:34

重新格式化文本非常简单,尽管我会等到失去焦点消息而不是在用户键入时插入冒号,但它会让人感到困惑,尤其是当他们需要编辑或删除字符时。

您可以通过获取 VK_TAB 在字段内实现制表位,但我不确定我会这样做 - 用户习惯于制表符跳转到下一个控件而不是控件内的位置。

另一种方法是使用 3 个独立的控件,但检测用户何时为第一个控件输入了足够的字符,或者输入了制表符(或冒号),然后自动将焦点切换到下一个控件。 我认为这更简洁,这就是 IP_ADDRESS 控件的作用。

Reformatting the text is simple enough, although I would wait until a lost focus message rather than insert colons while the user is typing, it gets confusing especially if they need to edit or delete a character.

You can implement tab stops within the field by getting VK_TAB but I'm not sure I would do this - users are used to tabs jumping to the next control not to positions within a control.

Another way to do this is to have 3 separate controls but detect when the user has entered enough characters for the first, or entered a tab (or colon) and then automatically switch focus to the next one. I think this is neater, it's what the IP_ADDRESS control does.

书信已泛黄 2024-08-06 14:54:34

您必须处理每个 WM_CHAR(或 WM_KEYUP,视情况而定)并在用户键入时重新格式化编辑框中的文本。 处理 VK_TAB 的消息并根据需要设置选择。

You'll have to handle each WM_CHAR (or WM_KEYUP, as appropriate) and re-format the text in the edit box as the user types. Handle the message for VK_TAB and set the selection as appropriate.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文