tags:

views:

429

answers:

3

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

A: 

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.

jeffamaphone
A: 

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.

Martin Beckett
That's what I figured I would have to do, now if I only could get it to be all whitespace between the fields like the IP_ADDRESS control.
dan.b.weber
A: 

I know this article doesn't get you quite where you want to be but I think the developer has implemented much of what you're asking about:

http://www.codeproject.com/KB/edit/datetimedit.aspx

Karim