-
Auto Tab Edit Controls
Hey, i'm thinking about writing a program where you would enter some numbers, but have separate edit controls for each number to be entered in. So I was wondering how I would make it so that after the user enters a number in one control, the program would automatically jump to the next edit control so the user can enter the next number.
:) thanks.
-
Ok first off I'm going to assume this is a child window not an dialog edit box control. It wouldn't be very hard to change around to work for an edit control though. Ok first off make a message loop for those controls:
Code:
LRESULT CALLBACK BoxProc(HWND,UINT,WPARAM,LPARAM);
//then define it
LRESULT CALLBACK BoxProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
switch(msg)
{
case EM_MAXTEXT:
SetFocus(nextWnd);
break;
}
return DefWindowProc(hwnd,msg,wParam,lParam);
}
To associate this procedure with the edit windows you might have to unregister the WNDCLASS after creating the initial window and register a new one that uses this. I think there is an easier way just can't remember it right now. Then when you create all those edit box windows use the same WNDCLASS for them all so they all will use this window procedure. Then when any of them reach their maximum text they will go to the next window. Remember to set nextWnd as a global HWND handle and make it grab the handle on the next window depending on which box is selected. Hope that helps, oh and don't forget to set a maximum text limit for those edit boxes. I'm kinda rushed so if I forgot something let me know. :)