Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cycling child windows with tab and defining the enter action C++

Status
Not open for further replies.

ambroz

Programmer
Aug 6, 2005
3
SI
I was trying to do this a long time, but with no success.
my code:

Code:
#include <windows.h>

using namespace std;

char* ClassName = "mywindowclass";

HWND hMain = NULL;

HWND hChild1 = NULL;
HWND hChild2= NULL;

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch(msg)
    {
        case WM_CLOSE:
             DestroyWindow(hwnd);
        break;
        case WM_DESTROY:
             PostQuitMessage(0);
        break;
        default:
            return DefWindowProc(hwnd, msg, wParam, lParam);
        break;
    }
    return 0;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow)
{
    WNDCLASSEX wc;
    MSG Msg;

    //create and register window class
    wc.cbSize        = sizeof(WNDCLASSEX);
    wc.style         = 0;
    wc.lpfnWndProc   = WndProc;
    wc.cbClsExtra    = 0;
    wc.cbWndExtra    = 0;
    wc.hInstance     = hInstance;
    wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)COLOR_BACKGROUND;
    wc.lpszMenuName  = NULL;
    wc.lpszClassName = ClassName;
    wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
    
    RegisterClassEx(&wc);

    //create main window
    hMain = CreateWindowEx(
        WS_EX_CONTROLPARENT,      //extended style
        ClassName,            //window class
        "The Main Window",        //name
        WS_OVERLAPPEDWINDOW,      //style
        CW_USEDEFAULT, CW_USEDEFAULT, 300, 300,
        NULL,          //parent window
        NULL,          //menu
        hInstance,     //program instance
        NULL
        );
    
    ShowWindow(hMain, nCmdShow);
    UpdateWindow(hMain);

    //CHILD WINDOWS
             hChild1=CreateWindowEx(WS_EX_CLIENTEDGE,"EDIT","",
             WS_VISIBLE|WS_CHILD|WS_TABSTOP,
             10,10,40,20,hMain,(HMENU)7001,hInstance,NULL);
             
             hChild2=CreateWindowEx(WS_EX_CLIENTEDGE,"EDIT","",
             WS_VISIBLE|WS_CHILD|WS_TABSTOP,
             60,10,40,20,hMain,(HMENU)7002,hInstance,NULL);
    //END OF CHILD WINDOWS
      
    while(GetMessage(&Msg, NULL, 0, 0) > 0)
    {
        TranslateMessage(&Msg);
        DispatchMessage(&Msg);
    }
    return Msg.wParam;
}

When I press the tab key while typing in the edit window, there is a beep.
I would also like to know how to define what happens if I am typing in the edit window and hitting the enter button.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top