From: Joseph M. Newcomer on
See below
On Mon, 5 May 2008 13:57:04 -0700, "David Ching" <dc(a)remove-this.dcsoft.com> wrote:

>"Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message
>news:c0mu14t6hb313a5u4771ua88jrt1j8vr70(a)4ax.com...
>> ON_CONTROL_RANGE(EN_CHANGE, IDC_FIELD1, IDC_FIELD5, OnChangeKeyField)
>>
>> void CMyDialog::OnEnChangeKeyField(UINT id)
>> {
>> CString s;
>> CWnd * wnd = GetDlgItem(id);
>> wnd->GetWindowText(s);
>> if(s.GetLength() == MAX_KEY_COMPONENT)
>> { /* filled */
>> CWnd * next = GetNextDlgTabItem(wnd);
>> next->SetFocus();
>> } /* filled */
>> }
>>
>> MAX_KEY_COMPONENT was set to 4 in our case, and there were 20 characters
>> in the key (5
>> fields of 4 characters each). The edit control was subclassed to only
>> allow [A-Z0-9\b] as
>> valid input characters, and was set to uppercase translation so lowercase
>> letters were
>> translated to uppercase.
>>
>
>Yes, but this only solves half the problem. It changes the focus to the
>next control. It doesn't erase the last character and re-type it into the
>next control.
***
It doesn't have to. It moves the focus to the next control AFTER the previous control is
filled, instead of WHEN it is overfilled.
****
>The way the problem was initially phrased, that is how it
>should work, although I see you attempt to achieve the same effect by moving
>the focus on the character before the overflow. That's the way I do it
>also, but that's not what the OP asked.
****
But my point is that he's asking the wrong question. He's asking how to make a flawed
implementation work, instead of asking how to solve the problem. So I showed how to solve
the problem using a different approach, which makes his question irrelevant because it is
no longer an issue about how to "retype" on an EN_MAXTEXT.
joe
****
>
>-- David
>
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Joseph M. Newcomer on
See below...
On 06 May 2008 02:53:23 GMT, David Scambler <Your_email(a)email.net> wrote:

>"David Ching" <dc(a)remove-this.dcsoft.com> wrote in
>news:wyKTj.15754$2g1.788(a)nlpi068.nbdc.sbc.com:
>
>> "Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message
>> news:c0mu14t6hb313a5u4771ua88jrt1j8vr70(a)4ax.com...
>>> ON_CONTROL_RANGE(EN_CHANGE, IDC_FIELD1, IDC_FIELD5, OnChangeKeyField)
>>>
>>> void CMyDialog::OnEnChangeKeyField(UINT id)
>>> {
>>> CString s;
>>> CWnd * wnd = GetDlgItem(id);
>>> wnd->GetWindowText(s);
>>> if(s.GetLength() == MAX_KEY_COMPONENT)
>>> { /* filled */
>>> CWnd * next = GetNextDlgTabItem(wnd);
>>> next->SetFocus();
>>> } /* filled */
>>> }
>>>
>>> MAX_KEY_COMPONENT was set to 4 in our case, and there were 20
>>> characters in the key (5
>>> fields of 4 characters each). The edit control was subclassed to
>>> only allow [A-Z0-9\b] as
>>> valid input characters, and was set to uppercase translation so
>>> lowercase letters were
>>> translated to uppercase.
>>>
>>
>> Yes, but this only solves half the problem. It changes the focus to
>> the next control. It doesn't erase the last character and re-type it
>> into the next control. The way the problem was initially phrased,
>> that is how it should work, although I see you attempt to achieve the
>> same effect by moving the focus on the character before the overflow.
>> That's the way I do it also, but that's not what the OP asked.
>
>Hmmm - seems even messier than that. What if the last character was not
>typed at the end of the field but was inserted at the start. What if a
>paste inserted a number of characters. Joe's
> (s.GetLength() == MAX_KEY_COMPONENT)
>will not compare true if the result of the paste exceeds
>MAX_KEY_COMPONENT.
****
Yes, you can handle a paste specially; I didn't give the complete code because it is
proprietary. However, if you try typing into almost any "key registration" form, you will
see that if you try to type more characters in, it just refuses to accept the characters
if the field is full, and if it isn't full, but the character completes it, the caret will
still move to the next field.

Also, we allowed the user to copy the full 20-digit key from an email and paste it into
the first box, and it would fill in all the others. That's code I can't show. I'm afraid
that accomplishing this has to be left as an Exercise For The Reader.


The options we provided were:

Receive a key by physical communication (snailmail, fax) and type it in
Receive a key by email and copy-and-paste the entire key into the first edit control
Do an interactive online registration and the key would be downloaded (based on your
product serial # which we uploaded)


joe
*****
>
>
>>
>> -- David
>>
>>
>>
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm