I would like to implement the TAB effect on multiple textboxes. Upon entering a value in a textbox and then hitting the enter key, the focus should automatically be moved to the next textbox (same as pressing the TAB key with focus in the textbox). Currently I am trying to use this piece of code in PreTranslateMessage():
if ( (pMsg->wParam == VK_RETURN) )
{
if( m_CeditCtrlLlaLatDegrees.GetFocus() )
{
keybd_event( VK_TAB,0x09,0,0);
// keybd_event( VK_TAB,0x09,KEYEVENTF_KEYUP,0);
}
}
The above code pushes the focus onto the textbox following the next immediate textbox (i.e. it moves 2 tabs ahead) There are 20 textboxes all taken from CEdit and all accept only numeric values.
How do I retrieve the ID for each of these textboxes? I tried assigning CEdit (control variable) and accessing the ID for each textbox, then through a switch-case statement I would check which textbox is active and then SetFocus() to the next immediate one (all of this in PreTranslateMessage()). But even this won't work.
Please suggest a way to get this to work. Please let me know the flow/code in detail since I am a newbie.