Hey,
I was just wondering how do I make my edit boxes so that when the the tab button is hit the cursor will go on to the next edit box in windows API. I've done some research on functions that deal with the cursor but I can't string them together to make something that works. Help please. Thanks.

Well yes, but how can I use that in order to do this?

If you use SetFocus on the handle to the text box, it should move the text cursor to there.
Just tried it, it worked.

How can I say, if the tab button is pushed, use SetFocus() ?
(I haven't dealt to much with code for saying if a certain button is pressed do something.)

How can I say, if the tab button is pushed, use SetFocus() ?

Show me your code.

Have you already programmed the functionality of the tabs? and do you have a HWND of the text box? If not, these are small details I can still help with.

I'm not sure how to create the functionality of the tabs.

Here is the best thing that I could come up for the tab functionality but it still doesn't work.

case WM_CHAR:
			switch(LOWORD(wParam2))
			{
				case 0x09: 
				{
					HWND hmove = GetDlgItem(hwnd2, IDC_POSTEXT);
					SetFocus(hmove);
				}
				break;
			}
		break;

Actually here's the code to the entire dialog Procedure:

BOOL CALLBACK DlgProc2(HWND hwnd2, UINT Message2, WPARAM wParam2, LPARAM lParam2)
{
	switch(Message2)
	{
		case WM_INITDIALOG:
			// This is where we set up the dialog box, and initialise any default values

			SetDlgItemText(hwnd2, IDC_STEXT,     "    Spanish");
			SetDlgItemText(hwnd2, IDC_ETEXT,     "    English");
			SetDlgItemText(hwnd2, IDC_POSTEXT,   "Part of Speech");
		break;
		
		case WM_CHAR:
			switch(wParam2)
			{
	                case 0x09:  // tab 
                       {                          
                           HWND hmove = GetDlgItem(hwnd2,IDC_POSTEXT);
                           SetFocus(hmove);
                        }
			}
		break;

		case WM_COMMAND:
			switch(LOWORD(wParam2))
			{
			case IDC_AWA:
			{
				int length = GetWindowTextLength(hRetrieve);
				LPCSTR pszText = "á";
				SendMessage(hRetrieve, EM_SETSEL, length, length + 1);
				SendMessage(hRetrieve, EM_REPLACESEL, true,(LPARAM) pszText); 
			}
			break;
			case IDC_EWA:
			{
				HWND edit = GetDlgItem(hwnd2, IDC_ANSQW);
				int length = GetWindowTextLength(edit);
				LPCSTR pszText = "é";
				SendMessage(edit, EM_SETSEL, length, length + 1);
				SendMessage(edit, EM_REPLACESEL, true,(LPARAM) pszText); 
			}
			break;
			case IDC_IWA:
			{
				HWND edit = GetDlgItem(hwnd2, IDC_ANSQW);
				int length = GetWindowTextLength(edit);
				LPCSTR pszText = "í";
				SendMessage(edit, EM_SETSEL, length, length + 1);
				SendMessage(edit, EM_REPLACESEL, true,(LPARAM) pszText); 
			}
			break;
			case IDC_OWA:
			{
				HWND edit = GetDlgItem(hwnd2, IDC_ANSQW);
				int length = GetWindowTextLength(edit);
				LPCSTR pszText = "ó";
				SendMessage(edit, EM_SETSEL, length, length + 1);
				SendMessage(edit, EM_REPLACESEL, true,(LPARAM) pszText); 
			}
			break;
			case IDC_UWA:
			{
				HWND edit = GetDlgItem(hwnd2, IDC_ANSQW);
				int length = GetWindowTextLength(edit);
				LPCSTR pszText = "ú";
				SendMessage(edit, EM_SETSEL, length, length + 1);
				SendMessage(edit, EM_REPLACESEL, true,(LPARAM) pszText); 
			}
			break;
			case IDC_NWT:
			{
				HWND edit = GetDlgItem(hwnd2, IDC_ANSQW);
				int length = GetWindowTextLength(edit);
				LPCSTR pszText = "ñ";
				SendMessage(edit, EM_SETSEL, length, length + 1);
				SendMessage(edit, EM_REPLACESEL, true,(LPARAM) pszText); 
			}
			break;
			case IDC_UQ:
			{
				HWND edit = GetDlgItem(hwnd2, IDC_ANSQW);
				int length = GetWindowTextLength(edit);
				LPCSTR pszText = "¿";
				SendMessage(edit, EM_SETSEL, length, length + 1);
				SendMessage(edit, EM_REPLACESEL, true,(LPARAM) pszText); 
			}
			case IDC_SAVE:	
				DoFileSave(hwnd2);
				EndDialog(hwnd2, 0);
				hwndGoto = NULL;
			break;
			}
		break;
		
		case WM_CLOSE:
			EndDialog(hwnd2, 0);
			hwndGoto = NULL;
		break;
		
		default:
			return FALSE;
	}
	return TRUE;
}

OK, after some research I figured out that I could use WS_TABSTOP but it's still not working. I have condensed my Program down so that you can see somewhat of the full code that I am dealing with.

The main.cpp

#include <windows.h>
#include "resource.h"

HWND hwndGoto = NULL;
/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

/*  Make the class name into a global variable  */
char szClassName[ ] = "WindowsApp";

int WINAPI WinMain (HINSTANCE hThisInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpszArgument,
                    int nFunsterStil)

{
    HWND hwnd;               /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */
    WNDCLASSEX wincl;        /* Data structure for the windowclass */

    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
    wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);

    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;                 /* No menu */
    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
    wincl.cbWndExtra = 0;                      /* structure or the window instance */
    /* Use Windows's default color as the background of the window */
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&wincl))
        return 0;

    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           "Windows App",       /* Title Text */
           WS_OVERLAPPEDWINDOW, /* default window */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /* where the window ends up on the screen */
           544,                 /* The programs width */
           375,                 /* and height in pixels */
           HWND_DESKTOP,        /* The window is a child-window to desktop */
           NULL,                /* No menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /* No Window Creation data */
           );

    /* Make the window visible on the screen */
    ShowWindow (hwnd, nFunsterStil);

    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&messages, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&messages);
    }

    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;
}

BOOL CALLBACK DlgProc(HWND hwnd2, UINT Message2, WPARAM wParam2, LPARAM lParam2)
{
	switch(Message2)
	{
		case WM_INITDIALOG:
			// This is where we set up the dialog box, and initialise any default values

			SetDlgItemText(hwnd2, IDC_ED,     "    Spanish");
			SetDlgItemText(hwnd2, IDC_ED2,     "    English");
		break;
		
		case WM_CLOSE:
			EndDialog(hwnd2, 0);
			hwndGoto = NULL;
		break;
		
		default:
			return FALSE;
	}
	return TRUE;
}

/*  This function is called by the Windows function DispatchMessage()  */

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)                  /* handle the messages */
    {
        case WM_KEYDOWN:
        {
             if(wParam == VK_SHIFT)
             {
                       HINSTANCE hinst = NULL;
                       hwndGoto = CreateDialog(hinst, MAKEINTRESOURCE(IDD_MAIN), hwnd, (DLGPROC)DlgProc); 
					   ShowWindow(hwndGoto, SW_SHOW);
              }
        }
        break;
        case WM_DESTROY:
            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
            break;
        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}

The resource.h

#define IDD_MAIN                10
#define IDC_ED					21
#define IDC_ED2                 22

the resource.rc

//Microsoft Developer Studio generated resource script.
//
#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#ifndef __BORLANDC__
#include "winres.h"
#endif

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE DISCARDABLE 
BEGIN
    "resource.h\0"
END

2 TEXTINCLUDE DISCARDABLE 
BEGIN
    "#ifndef __BORLANDC__\r\n"
    "#include ""winres.h""\r\n"
    "#endif\r\n"
    "\0"
END

3 TEXTINCLUDE DISCARDABLE 
BEGIN
    "\0"
END

#endif    // APSTUDIO_INVOKED




/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//

IDD_MAIN DIALOG DISCARDABLE  0, 0, 650, 151
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Spanish Word Editor"
FONT 8, "MS Sans Serif"
BEGIN
    EDITTEXT        IDC_ED,0,7,50,14,ES_AUTOHSCROLL | WS_TABSTOP
    EDITTEXT        IDC_ED2,60,7,50,14,ES_AUTOHSCROLL | WS_TABSTOP
END

/////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//

#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE 
BEGIN
    IDD_MAIN, DIALOG
    BEGIN
        LEFTMARGIN, 7
        RIGHTMARGIN, 200
        VERTGUIDE, 145
        VERTGUIDE, 150
        TOPMARGIN, 7
        BOTTOMMARGIN, 149
    END

#endif    // APSTUDIO_INVOKED

#endif    // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////

If it's the default tab-control, then your event handler should look somewhat like this:

case WM_NOTIFY:
      {
        HWND tabs = GetDlgItem(hDlg, IDC_TABS);
        switch ( ((LPNMHDR)lParam)->code ) {
          case TCN_SELCHANGE:
            {
              selectedTab = TabCtrl_GetCurSel( tabs );
              // Code here
            }
            break;
        }
      }
      break;

But looking through your resource code, I don't see any sign of a SysTabControl32 box, what are you using for your tabs?

I'm not following your code very well, could you please explain it? And shouldn't the tab stop style fix my problem because from the research that I've done, It should do exactly what I want it to. Do you know why those tab stops aren't working.

Never mind. I figured it all out. Thanks for all of your help. I had to use the IsDialogMessage function properly.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.